Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eng 3038 incorrect machine #63

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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