Skip to content

Commit

Permalink
Merge pull request #63 from sightmachine/ENG-3038-incorrect_machine
Browse files Browse the repository at this point in the history
Eng 3038 incorrect machine
  • Loading branch information
ankitintg authored Dec 8, 2023
2 parents bd9fbe1 + 3185c8d commit 4c42e54
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions smsdk/ma_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_records_v1(
url_params["db_mode"] = db_mode

# print(f'Pulling up to {this_loop_limit} records ({remaining_limit} remain)')

response = None
try:
response = getattr(self.session, method.lower())(
endpoint, json=url_params
Expand All @@ -191,7 +191,7 @@ def _get_records_v1(
f"Error connecting to {endpoint}. Check your tenant name"
)

if response and response.text:
if response is not None and response.text:
if response.status_code not in [200, 201]:
raise ValueError(format(response.text))
try:
Expand Down
15 changes: 15 additions & 0 deletions tests/kpi/test_kpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 4c42e54

Please sign in to comment.