Skip to content

Commit

Permalink
fix filtered check
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereiracgn committed Dec 10, 2024
1 parent 7b7d82b commit 5a77f2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions tests/tests_integration/test_api/test_simulators/seed/data.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time

import pytest

from cognite.client import CogniteClient
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"]])
)
Expand All @@ -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
Expand Down

0 comments on commit 5a77f2e

Please sign in to comment.