From 5a77f2ec6602b2f025d7e908009fde0da57acebe Mon Sep 17 00:00:00 2001 From: Luis Pereira Date: Tue, 10 Dec 2024 10:28:02 +0100 Subject: [PATCH] fix filtered check --- .../test_api/test_simulators/seed/data.py | 5 +++-- .../test_simulators/test_simulators.py | 20 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/tests_integration/test_api/test_simulators/seed/data.py b/tests/tests_integration/test_api/test_simulators/seed/data.py index b8e6acfa2..d865bfdfc 100644 --- a/tests/tests_integration/test_api/test_simulators/seed/data.py +++ b/tests/tests_integration/test_api/test_simulators/seed/data.py @@ -1,7 +1,8 @@ import time -data_set_id = 1521375514069 -development_data_set_id = 97552494921583 +# data_set_id = 1521375514069 +# development_data_set_id = 97552494921583 +data_set_id = 97552494921583 resource_names = { "simulator_external_id": "py_sdk_integration_tests", diff --git a/tests/tests_integration/test_api/test_simulators/test_simulators.py b/tests/tests_integration/test_api/test_simulators/test_simulators.py index 04148373b..0790f285c 100644 --- a/tests/tests_integration/test_api/test_simulators/test_simulators.py +++ b/tests/tests_integration/test_api/test_simulators/test_simulators.py @@ -1,4 +1,5 @@ import time + import pytest from cognite.client import CogniteClient @@ -41,18 +42,16 @@ def seed_simulator(cognite_client: CogniteClient, seed_resource_names) -> None: simulator_external_id = seed_resource_names["simulator_external_id"] simulators = cognite_client.simulators.list() simulator_exists = len(list(filter(lambda x: x.external_id == simulator_external_id, simulators))) > 0 - if not simulator_exists: + if simulator_exists: cognite_client.post( - f"/api/v1/projects/{cognite_client.config.project}/simulators", - json={"items": [simulator]}, + f"/api/v1/projects/{cognite_client.config.project}/simulators/delete", + json={"items": [{"externalId": seed_resource_names["simulator_external_id"]}]}, ) - # yield - - # cognite_client.post( - # f"/api/v1/projects/{cognite_client.config.project}/simulators/delete", - # json={"items": [{"externalId": seed_resource_names["simulator_external_id"]}]}, - # ) + cognite_client.post( + f"/api/v1/projects/{cognite_client.config.project}/simulators", + json={"items": [simulator]}, + ) @pytest.fixture @@ -124,7 +123,6 @@ def test_list_simulators(self, cognite_client: CogniteClient) -> None: assert len(simulators) > 0 - class TestSimulatorIntegrations: @pytest.mark.usefixtures("seed_resource_names", "seed_simulator_integration") def test_list_integrations(self, cognite_client: CogniteClient) -> None: @@ -137,6 +135,7 @@ def test_filter_integrations(self, cognite_client: CogniteClient, seed_resource_ active_integrations = cognite_client.simulators.integrations.list( filter=SimulatorIntegrationFilter(active=True) ) + filtered_integrations = cognite_client.simulators.integrations.list( filter=SimulatorIntegrationFilter(simulator_external_ids=[seed_resource_names["simulator_external_id"]]) ) @@ -145,7 +144,6 @@ def test_filter_integrations(self, cognite_client: CogniteClient, seed_resource_ assert filtered_integrations[0].simulator_external_id == seed_resource_names["simulator_external_id"] # check time difference assert filtered_integrations[0].active is True - assert filtered_integrations[0].heartbeat == 10 assert len(active_integrations) > 0 assert len(filtered_integrations) > 0