Skip to content

Commit 511b8ca

Browse files
authored
Merge pull request #1165 from janmatzek/jmat-SVS-1203-use-orjson-to-load-test-data-in-gooddata-pipelines
chore:(gooddata-pipelines): user orjson to load test data
2 parents e4c488f + 3056398 commit 511b8ca

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

gooddata-pipelines/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ moto = ">=5.1.6,<6.0.0"
3333
pytest = ">=8.3.5,<9.0.0"
3434
pytest-mock = ">=3.14.0,<4.0.0"
3535
ruff = ">=0.11.2,<0.12.0"
36+
orjson = "^3.11.3"
3637

3738
[build-system]
3839
requires = ["hatchling"]

gooddata-pipelines/tests/provisioning/entities/users/test_permissions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) 2025 GoodData Corporation
2-
import json
32
from typing import Literal
43

4+
import orjson
55
import pytest
66
from gooddata_api_client.exceptions import ( # type: ignore[import]
77
NotFoundException,
@@ -455,7 +455,7 @@ def test_permission_provisioner(
455455
f"{TEST_DATA_SUBDIR}/existing_upstream_permissions.json"
456456
)
457457
with open(EXISTING_UPSTREAM_PERMISSIONS_PATH, "r") as f:
458-
raw_existing_upstream_permissions = json.load(f)
458+
raw_existing_upstream_permissions = orjson.loads(f.read())
459459

460460
existing_upstream_permissions = parse_expected_permissions(
461461
raw_existing_upstream_permissions
@@ -477,11 +477,11 @@ def mock_get_declarative_permissions(
477477

478478
# Load source data
479479
with open(f"{TEST_DATA_SUBDIR}/{source_data_path}", "r") as f:
480-
source_data = json.load(f)
480+
source_data = orjson.loads(f.read())
481481

482482
# Load and parse expected data
483483
with open(f"{TEST_DATA_SUBDIR}/{expected_data_path}", "r") as f:
484-
raw_expected_result = json.load(f)
484+
raw_expected_result = orjson.loads(f.read())
485485

486486
expected_result = parse_expected_permissions(raw_expected_result)
487487

gooddata-pipelines/tests/provisioning/entities/users/test_users.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# (C) 2025 GoodData Corporation
2-
import json
32
from dataclasses import dataclass
43
from typing import Literal, Optional
54

5+
import orjson
66
import pytest
77
from gooddata_api_client.exceptions import NotFoundException # type: ignore
88
from gooddata_sdk.catalog.user.entity_model.user import (
@@ -225,15 +225,15 @@ def test_user_provisioning(
225225

226226
# Load input data
227227
with open(f"{TEST_DATA_SUBDIR}/{input_path}", "r") as f:
228-
input_data = json.load(f)
228+
input_data = orjson.loads(f.read())
229229

230230
# Load expected data
231231
with open(f"{TEST_DATA_SUBDIR}/{expected_path}", "r") as f:
232-
raw_expected_data = json.load(f)
232+
raw_expected_data = orjson.loads(f.read())
233233

234234
# Load and patch "existing users"
235235
with open(f"{TEST_DATA_SUBDIR}/existing_upstream_users.json", "r") as f:
236-
raw_upstream_users = json.load(f)
236+
raw_upstream_users = orjson.loads(f.read())
237237

238238
upstream_users = parse_user_data(raw_upstream_users)
239239

gooddata-pipelines/tests/provisioning/entities/workspaces/test_workspace_data_filters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# (C) 2025 GoodData Corporation
22

3-
import json
43
from typing import Any
54

5+
import orjson
66
import pytest
77
from pydantic import ValidationError
88
from requests import Response
@@ -67,7 +67,7 @@ def test_get_wdf_settings_for_workspace_valid_payload(
6767

6868
payload = WDF_VALID_PAYLOAD
6969

70-
mock_response._content = json.dumps(payload).encode("utf-8")
70+
mock_response._content = orjson.dumps(payload)
7171

7272
mocker.patch.object(
7373
mock_gooddata_api,
@@ -102,7 +102,7 @@ def test_get_wdf_settings_for_workspace_invalid_payload(
102102
]
103103
}
104104

105-
mock_response._content = json.dumps(payload).encode("utf-8")
105+
mock_response._content = orjson.dumps(payload)
106106

107107
mocker.patch.object(
108108
mock_gooddata_api,

gooddata-pipelines/tests/test_ldm_extension/test_models/test_analytical_object.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# (C) 2025 GoodData Corporation
2-
import json
3-
2+
import orjson
43
import pytest
54

65
from gooddata_pipelines.ldm_extension.models.analytical_object import (
@@ -20,7 +19,7 @@
2019
)
2120
def test_analytical_object_model_with_metrics(file_path):
2221
with open(file_path, "r") as file:
23-
data = json.load(file)
22+
data = orjson.loads(file.read())
2423
analytical_objects = AnalyticalObjects(**data)
2524
assert isinstance(analytical_objects, AnalyticalObjects)
2625
assert isinstance(analytical_objects.data, list)

0 commit comments

Comments
 (0)