Skip to content

Commit

Permalink
Bug node apply (#1854)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored Jul 20, 2024
1 parent d004f95 commit 71beffe
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.54.6] - 2024-07-19
### Fixed
- In the data classe, `NodeApply` and `EdgeApply` the argument `camel_case=False` is now
respected in `.dump()`.

## [7.54.5] - 2024-07-19
### Changed
- [Feature Preview] Updated the Core Model to the newest version released on July 12th, 2024. The
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.54.5"
__version__ = "7.54.6"
__api_subversion__ = "20230101"
4 changes: 2 additions & 2 deletions cognite/client/data_classes/data_modeling/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ def dump(self, camel_case: bool = True) -> dict[str, Any]:
output: dict[str, Any] = {
"space": self.space,
"externalId" if camel_case else "external_id": self.external_id,
"instanceType": self.instance_type,
"instanceType" if camel_case else "instance_type": self.instance_type,
}
if self.existing_version is not None:
output["existingVersion"] = self.existing_version
output["existingVersion" if camel_case else "existing_version"] = self.existing_version
if self.sources:
output["sources"] = [source.dump(camel_case) for source in self.sources]
return output
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.54.5"
version = "7.54.6"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ def test_dump_and_load(self) -> None:
"endNode": {"space": "mySpace", "externalId": "actor.external_id"},
}

def test_dump_camel_case_false(self) -> None:
edge = EdgeApply(
space="mySpace",
external_id="relation:arnold_schwarzenegger:actor",
type=DirectRelationReference("mySpace", "Person.role"),
start_node=DirectRelationReference("mySpace", "source"),
end_node=DirectRelationReference("mySpace", "target"),
)

assert edge.dump(camel_case=False) == {
"space": "mySpace",
"external_id": "relation:arnold_schwarzenegger:actor",
"instance_type": "edge",
"type": {
"space": "mySpace",
"external_id": "Person.role",
},
"start_node": {
"space": "mySpace",
"external_id": "source",
},
"end_node": {"space": "mySpace", "external_id": "target"},
}


class TestNodeOrEdgeData:
def test_direct_relation_serialization(self) -> None:
Expand Down Expand Up @@ -143,6 +167,18 @@ def test_dump_and_load(self) -> None:
"type": {"externalId": "someType", "space": "someSpace"},
}

def test_dump_camel_case_false(self) -> None:
node = NodeApply(
space="IntegrationTestsImmutable",
external_id="shop:case:integration_test",
)

assert node.dump(camel_case=False) == {
"external_id": "shop:case:integration_test",
"instance_type": "node",
"space": "IntegrationTestsImmutable",
}


class TestNode:
def test_dump_and_load(self) -> None:
Expand Down

0 comments on commit 71beffe

Please sign in to comment.