Skip to content

Commit

Permalink
Send native JSON-objects instead of JSON-string. Add streaming (#397)
Browse files Browse the repository at this point in the history
* Send native JSON-objects instead of JSON-string. Add streaming

* bump version

* fix tests

* remove streaming as default for field-based
  • Loading branch information
mallport authored May 23, 2024
1 parent 42e45f7 commit ef9c94c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dapla-toolbelt-pseudo"
version = "2.0.2"
version = "2.0.3"
description = "Pseudonymization extensions for Dapla"
authors = ["Dapla Developers <[email protected]>"]
license = "MIT"
Expand Down
1 change: 0 additions & 1 deletion src/dapla_pseudo/v1/baseclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def _pseudonymize_file(
path=f"{self._pseudo_operation.value}/file",
request_spec=request_spec,
data_spec=data_spec,
stream=True,
timeout=timeout,
)
file_handle.close()
Expand Down
6 changes: 3 additions & 3 deletions src/dapla_pseudo/v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def _post_to_file_endpoint(
path: str,
request_spec: FileSpecDecl,
data_spec: FileSpecDecl,
stream: bool,
timeout: int,
stream: bool = True,
) -> requests.Response:
"""POST to a file endpoint in the Pseudo Service.
Expand Down Expand Up @@ -111,7 +111,7 @@ def _post_to_field_endpoint(
"Content-Type": Mimetypes.JSON.value,
"X-Correlation-Id": PseudoClient._generate_new_correlation_id(),
},
json={"request": pseudo_field_request.model_dump_json(by_alias=True)},
json={"request": pseudo_field_request.model_dump(by_alias=True)},
stream=stream,
timeout=timeout,
)
Expand All @@ -124,7 +124,7 @@ def _post_to_sid_endpoint(
path: str,
values: list[str],
sid_snapshot_date: date | None = None,
stream: bool = False,
stream: bool = True,
) -> requests.Response:
request: dict[str, t.Collection[str]] = {"fnrList": values}
response = requests.post(
Expand Down
4 changes: 2 additions & 2 deletions tests/v1/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_post_to_field_endpoint_serialization(
pseudo_field_request=pseudo_field_request,
timeout=TIMEOUT_DEFAULT,
)
expected_json = {"request": pseudo_field_request.model_dump_json(by_alias=True)}
expected_json = {"request": pseudo_field_request.model_dump(by_alias=True)}

_mock_post.assert_called_once_with(
url="https://mocked.dapla-pseudo-service/test_path",
Expand Down Expand Up @@ -130,6 +130,6 @@ def test_successful_post_to_sid_endpoint(
"X-Correlation-Id": ANY,
},
json=expected_json,
stream=False,
stream=True,
timeout=TIMEOUT_DEFAULT,
)

0 comments on commit ef9c94c

Please sign in to comment.