Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereiracgn committed Dec 12, 2024
1 parent 433e585 commit 9428ecb
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 131 deletions.
7 changes: 6 additions & 1 deletion cognite/client/_api/simulators/simulation_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from cognite.client._api_client import APIClient
from cognite.client._constants import DEFAULT_LIMIT_READ
from cognite.client.data_classes.simulators.filters import SimulationRunsFilter
from cognite.client.data_classes.simulators.simulators import SimulationRun, SimulationRunsList, CreatedTimeSort, SimulationTimeSort
from cognite.client.data_classes.simulators.simulators import (
CreatedTimeSort,
SimulationRun,
SimulationRunsList,
SimulationTimeSort,
)
from cognite.client.utils._experimental import FeaturePreviewWarning

if TYPE_CHECKING:
Expand Down
32 changes: 16 additions & 16 deletions cognite/client/_api/simulators/simulator_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from cognite.client._constants import DEFAULT_LIMIT_READ
from cognite.client.data_classes.simulators.filters import SimulatorModelRevisionsFilter, SimulatorModelsFilter
from cognite.client.data_classes.simulators.simulators import (
CreatedTimeSort,
SimulatorModel,
SimulatorModelList,
SimulatorModelRevision,
SimulatorModelRevisionList,
CreatedTimeSort
)
from cognite.client.utils._experimental import FeaturePreviewWarning
from cognite.client.utils._identifier import IdentifierSequence
Expand All @@ -34,7 +34,7 @@ def list(
self,
limit: int = DEFAULT_LIMIT_READ,
sort: CreatedTimeSort | None = None,
filter: SimulatorModelRevisionsFilter | dict[str, Any] | None = None
filter: SimulatorModelRevisionsFilter | dict[str, Any] | None = None,
) -> SimulatorModelRevisionList:
"""`Filter simulator model revisions <https://developer.cognite.com/api#tag/Simulator-Models/operation/filter_simulator_model_revisions_simulators_models_revisions_list_post>`_
Expand Down Expand Up @@ -108,25 +108,25 @@ def retrieve_multiple(
) -> SimulatorModelRevisionList:
"""`Retrieve simulator model revisions <https://developer.cognite.com/api#tag/Simulator-Models/operation/retrieve_simulator_model_revisions_simulators_models_revisions_byids_post>`_
Retrieve one or more simulator model revisions by IDs or external IDs.
Retrieve one or more simulator model revisions by IDs or external IDs.
Args:
ids (Sequence[int] | None): IDs
external_ids (SequenceNotStr[str] | None): External IDs
ignore_unknown_ids (bool): Ignore IDs and external IDs that are not found rather than throw an exception.
Args:
ids (Sequence[int] | None): IDs
external_ids (SequenceNotStr[str] | None): External IDs
ignore_unknown_ids (bool): Ignore IDs and external IDs that are not found rather than throw an exception.
Returns:
SimulatorModelRevisionList: Requested simulator model revisions
Returns:
SimulatorModelRevisionList: Requested simulator model revisions
Examples:
Examples:
Get simulator model revisions by ids:
>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.simulators.models.revisions.retrieve_multiple(ids=[1, 2, 3])
Get simulator model revisions by ids:
>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.simulators.models.revisions.retrieve_multiple(ids=[1, 2, 3])
Get simulator model revisions by external ids:
>>> res = client.simulators.models.revisions.retrieve_multiple(external_ids=["abc", "def"])
Get simulator model revisions by external ids:
>>> res = client.simulators.models.revisions.retrieve_multiple(external_ids=["abc", "def"])
"""
identifiers = IdentifierSequence.load(ids=ids, external_ids=external_ids)
return self._retrieve_multiple(
Expand Down
38 changes: 20 additions & 18 deletions cognite/client/_api/simulators/simulator_routines.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any

from cognite.client._api_client import APIClient
from cognite.client._constants import DEFAULT_LIMIT_READ
from cognite.client.data_classes.simulators.filters import SimulatorRoutineRevisionsFilter, SimulatorRoutinesFilter
from cognite.client.data_classes.simulators.simulators import (
CreatedTimeSort,
SimulatorRoutine,
SimulatorRoutineList,
SimulatorRoutineRevision,
SimulatorRoutineRevisionsList,
CreatedTimeSort,
)
from cognite.client.utils._experimental import FeaturePreviewWarning
from cognite.client.utils._identifier import IdentifierSequence
Expand All @@ -20,6 +20,7 @@
if TYPE_CHECKING:
from cognite.client import ClientConfig, CogniteClient


class SimulatorRoutineRevisionsAPI(APIClient):
_RESOURCE_PATH = "/simulators/routines/revisions"

Expand All @@ -31,7 +32,7 @@ def __init__(self, config: ClientConfig, api_version: str | None, cognite_client

def list(
self,
limit: int = 20, # the maximum number of revisions to return is limited to 20 items.
limit: int = 20, # the maximum number of revisions to return is limited to 20 items.
sort: CreatedTimeSort | None = None,
filter: SimulatorRoutineRevisionsFilter | dict[str, Any] | None = None,
includeAllFields: bool = False,
Expand Down Expand Up @@ -109,25 +110,25 @@ def retrieve_multiple(
) -> SimulatorRoutineRevisionsList:
"""`Retrieve simulator routine revisions <https://developer.cognite.com/api#tag/Simulator-Routines/operation/retrieve_simulator_routine_revisions_simulators_routines_revisions_byids_post>`_
Retrieve one or more simulator routine revisions by IDs or external IDs
Retrieve one or more simulator routine revisions by IDs or external IDs
Args:
ids (Sequence[int] | None): IDs
external_ids (SequenceNotStr[str] | None): External IDs
ignore_unknown_ids (bool): Ignore IDs and external IDs that are not found rather than throw an exception.
Args:
ids (Sequence[int] | None): IDs
external_ids (SequenceNotStr[str] | None): External IDs
ignore_unknown_ids (bool): Ignore IDs and external IDs that are not found rather than throw an exception.
Returns:
SimulatorRoutineRevisionsList: Requested simulator routine revisions
Returns:
SimulatorRoutineRevisionsList: Requested simulator routine revisions
Examples:
Examples:
Get simulator routine revisions by id:
>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.simulators.routines.revisions.retrieve_multiple(ids=[1, 2, 3])
Get simulator routine revisions by id:
>>> from cognite.client import CogniteClient
>>> client = CogniteClient()
>>> res = client.simulators.routines.revisions.retrieve_multiple(ids=[1, 2, 3])
Get simulator routine revisions by external id:
>>> res = client.simulators.routines.revisions.retrieve_multiple(external_ids=["abc", "def"])
Get simulator routine revisions by external id:
>>> res = client.simulators.routines.revisions.retrieve_multiple(external_ids=["abc", "def"])
"""
identifiers = IdentifierSequence.load(ids=ids, external_ids=external_ids)
return self._retrieve_multiple(
Expand All @@ -150,7 +151,8 @@ def __init__(self, config: ClientConfig, api_version: str | None, cognite_client

def list(
self,
limit: int = DEFAULT_LIMIT_READ, filter: SimulatorRoutinesFilter | dict[str, Any] | None = None,
limit: int = DEFAULT_LIMIT_READ,
filter: SimulatorRoutinesFilter | dict[str, Any] | None = None,
sort: CreatedTimeSort | None = None,
) -> SimulatorRoutineList:
"""`Filter simulator routines <https://developer.cognite.com/api#tag/Simulator-Routines/operation/filter_simulator_routines_simulators_routines_list_post>`_
Expand Down
82 changes: 41 additions & 41 deletions cognite/client/data_classes/simulators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,56 +56,56 @@
)

__all__ = [
"SimulationRun",
"SimulationRunCore",
"SimulationRunsList",
"SimulationValueUnitInput",
"SimulatorRoutineInputTimeseries",
"SimulatorRoutineInputConstant",
"SimulatorRoutineOutput",
"SimulatorRoutineSchedule",
"SimulatorRoutineDataSampling",
"SimulatorRoutineLogicalCheckEnabled",
"SimulatorRoutineSteadyStateDetectionEnabled",
"SimulatorRoutineConfiguration",
"SimulatorRoutineStepArguments",
"SimulatorRoutineStep",
"SimulatorRoutineStage",
"SimulatorUnitEntry",
"SimulatorStepOption",
"SimulatorModelType",
"SimulatorQuantity",
"SimulatorStepField",
"SimulatorStep",
"SimulatorCore",
"SimulatorWrite",
"Simulator",
"SimulatorCore",
"SimulatorIntegration",
"SimulatorIntegrationCore",
"SimulatorIntegrationList",
"SimulatorIntegrationWrite",
"SimulatorIntegration",
"SimulatorIntegrationWriteList",
"SimulatorList",
"SimulatorModel",
"SimulatorModelCore",
"SimulatorModelList",
"SimulatorModelRevision",
"SimulatorModelRevisionCore",
"SimulatorModelRevisionList",
"SimulatorModelRevisionWrite",
"SimulatorModelRevision",
"SimulatorRoutineRevisionCore",
"SimulatorRoutineRevisionWrite",
"SimulatorRoutineRevision",
"SimulatorModelCore",
"SimulatorModelRevisionWriteList",
"SimulatorModelType",
"SimulatorModelWrite",
"SimulatorModel",
"SimulationRunCore",
"SimulationRun",
"SimulatorRoutineCore",
"SimulatorRoutineWrite",
"SimulatorModelWriteList",
"SimulatorQuantity",
"SimulatorRoutine",
"SimulatorRoutineRevisionWriteList",
"SimulatorRoutineRevisionList",
"SimulatorRoutineWriteList",
"SimulatorRoutineConfiguration",
"SimulatorRoutineCore",
"SimulatorRoutineDataSampling",
"SimulatorRoutineInputConstant",
"SimulatorRoutineInputTimeseries",
"SimulatorRoutineList",
"SimulatorRoutineLogicalCheckEnabled",
"SimulatorRoutineOutput",
"SimulatorRoutineRevision",
"SimulatorRoutineRevisionCore",
"SimulatorRoutineRevisionList",
"SimulatorRoutineRevisionWrite",
"SimulatorRoutineRevisionWriteList",
"SimulatorRoutineRevisionsList",
"SimulatorRoutineSchedule",
"SimulatorRoutineStage",
"SimulatorRoutineSteadyStateDetectionEnabled",
"SimulatorRoutineStep",
"SimulatorRoutineStepArguments",
"SimulatorRoutineWrite",
"SimulatorRoutineWriteList",
"SimulatorStep",
"SimulatorStepField",
"SimulatorStepOption",
"SimulatorUnitEntry",
"SimulatorWrite",
"SimulatorWriteList",
"SimulatorList",
"SimulatorIntegrationWriteList",
"SimulatorIntegrationList",
"SimulatorModelWriteList",
"SimulatorModelList",
"SimulatorModelRevisionWriteList",
"SimulatorModelRevisionList",
"SimulationRunsList",
]
10 changes: 5 additions & 5 deletions cognite/client/data_classes/simulators/simulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
from abc import ABC
from collections.abc import Sequence
from dataclasses import dataclass
from enum import auto
from typing import TYPE_CHECKING, Any, Literal, TypeAlias
from typing import TYPE_CHECKING, Any, Literal

from typing_extensions import Self

from cognite.client.data_classes._base import (
CogniteObject,
CogniteResource,
CogniteResourceList,
CogniteSort,
ExternalIDTransformerMixin,
IdTransformerMixin,
InternalIdTransformerMixin,
WriteableCogniteResource,
WriteableCogniteResourceList,
EnumProperty,
CogniteSort
)
from cognite.client.utils.useful_types import SequenceNotStr

Expand Down Expand Up @@ -1530,12 +1528,12 @@ def __hash__(self) -> int:


class PropertySort(CogniteSort):

def dump(self, camel_case: bool = True) -> dict[str, Any]:
dumped = super().dump(camel_case=camel_case)
dumped["property"] = self.property
return dumped


class CreatedTimeSort(PropertySort):
def __init__(
self,
Expand All @@ -1544,6 +1542,7 @@ def __init__(
):
super().__init__(property, order)


class SimulationTimeSort(PropertySort):
def __init__(
self,
Expand All @@ -1552,6 +1551,7 @@ def __init__(
):
super().__init__(property, order)


class SimulatorRoutineRevisionWriteList(CogniteResourceList[SimulatorRoutineRevisionWrite], ExternalIDTransformerMixin):
_RESOURCE = SimulatorRoutineRevisionWrite

Expand Down
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
Loading

0 comments on commit 9428ecb

Please sign in to comment.