Skip to content

Commit

Permalink
fixup! Support InstanceReferences filter for Data Modeling
Browse files Browse the repository at this point in the history
  • Loading branch information
erlendvollset committed Jan 6, 2025
1 parent bcf58f8 commit 0875dc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cognite/client/data_classes/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def load(cls, filter_: dict[str, Any]) -> Filter:
filter_type=filter_body["filterType"],
)
elif (filter_body := filter_.get(InstanceReferences._filter_name)) is not None:
return InstanceReferences(references=filter_body["references"])
return InstanceReferences(references=filter_body)
else:
filter_name, filter_body = next(iter(filter_.items()))
return UnknownFilter(filter_name, filter_body)
Expand Down Expand Up @@ -952,7 +952,7 @@ class InstanceReferences(Filter):
"""Data modeling filter which matches filters with these fully qualified instance refs.
Args:
references (Sequence[tuple[str, str]] | Sequence[InstanceId]): The instance references.
references (Sequence[InstanceId] | Sequence[tuple[str, str]]): The instance references.
Example:
Filter than can be used to retrieve instances where their space/externalId matches any of the provided values:
Expand All @@ -969,7 +969,7 @@ class InstanceReferences(Filter):

_filter_name = "instanceReferences"

def __init__(self, references: Sequence[tuple[str, str]] | Sequence[InstanceId]) -> None:
def __init__(self, references: Sequence[InstanceId] | Sequence[tuple[str, str]]) -> None:
self.__references = [InstanceId.load(ref) for ref in references]

def _filter_body(self, camel_case_property: bool) -> list:
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_unit/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_writable_list_as_write(
self, writable_list: type[WriteableCogniteResourceList], cognite_mock_client_placeholder
):
resource_cls = writable_list._RESOURCE
instance_generator = FakeCogniteResourceGenerator(seed=53, cognite_client=cognite_mock_client_placeholder)
instance_generator = FakeCogniteResourceGenerator(seed=52, cognite_client=cognite_mock_client_placeholder)
instance = instance_generator.create_instance(resource_cls)
# Setting the cognite_client to None as the `as_write` should not fail if the client is not set.
instance_list = writable_list([instance], cognite_client=None)
Expand Down

0 comments on commit 0875dc6

Please sign in to comment.