From 3185c8d80fc3e6693b5f909b631aac908e6e599a Mon Sep 17 00:00:00 2001 From: anknitintg Date: Fri, 8 Dec 2023 17:32:23 +0530 Subject: [PATCH] Added unit test to check value error when getting incorrect machine --- tests/kpi/test_kpi.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/kpi/test_kpi.py b/tests/kpi/test_kpi.py index d39ccd4..fa1e973 100644 --- a/tests/kpi/test_kpi.py +++ b/tests/kpi/test_kpi.py @@ -4,6 +4,7 @@ from tests.kpi.kpi_data import AVALIBLE_KPI_JSON, KPI_DATA_VIZ_JSON from smsdk.smsdk_entities.kpi.kpi import KPI from mock import mock_open, MagicMock, patch +import unittest @patch("smsdk.ma_session.Session") @@ -112,6 +113,20 @@ def test_kpi_for_asset_display_name(get_client): assert df1 == df2 +def test_kpi_for_asset_incorrect_machine(get_client): + kpis = ["performance", "oee", "quality", "availability"] + # Query against machine that does not exist in the system. + query = { + "asset_selection": { + "machine_type": ["PickAndPlace"], + "machine_source": ["incorrect"], + } + } + # Expecting a value error while tring to get KPIs for incorrect machine. + with unittest.TestCase().assertRaises(ValueError) as context: + df1 = get_client.get_kpis_for_asset(**query) + + def test_get_kpi_data_viz(get_client): machine_sources = ["Nagoya - Pick and Place 6"] kpis = ["quality"]