Skip to content

Commit 5061ac3

Browse files
authored
Ingest test refactor (#253)
* Add ingest json builder * wip * Fixes * Add json builder helper function and replace test files in integration tests * Replace test json in unit tests with builder * Bump patch version * Bump patch version * Refactor to make test data creation more readable * Simplify adjusting test data with destructuring
1 parent f549e9a commit 5061ac3

File tree

9 files changed

+234
-381
lines changed

9 files changed

+234
-381
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "admin_backend"
3-
version = "2.17.15"
3+
version = "2.17.16"
44
description = ""
55
authors = ["CPR-dev-team <[email protected]>"]
66
packages = [{ include = "app" }, { include = "tests" }]

tests/helpers/ingest.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import json
2+
import logging
3+
from io import BytesIO
4+
from typing import Any
5+
6+
logger = logging.getLogger(__name__)
7+
8+
9+
default_collection = {
10+
"import_id": "test.new.collection.0",
11+
"title": "Test title",
12+
"description": "Test description",
13+
}
14+
15+
16+
default_family = {
17+
"import_id": "test.new.family.0",
18+
"title": "Test",
19+
"summary": "Test",
20+
"geographies": ["South Asia"],
21+
"category": "UNFCCC",
22+
"metadata": {"author_type": ["Non-Party"], "author": ["Test"]},
23+
"collections": ["test.new.collection.0"],
24+
}
25+
26+
27+
default_document = {
28+
"import_id": "test.new.document.0",
29+
"family_import_id": "test.new.family.0",
30+
"metadata": {"role": ["MAIN"], "type": ["Law"]},
31+
"variant_name": None,
32+
"title": "",
33+
"user_language_name": "",
34+
}
35+
36+
37+
default_event = {
38+
"import_id": "test.new.event.0",
39+
"family_import_id": "test.new.family.0",
40+
"event_title": "Test",
41+
"date": "2024-01-01",
42+
"event_type_value": "Amended",
43+
}
44+
45+
46+
def build_json_file(data: dict[str, Any]) -> BytesIO:
47+
json_data = json.dumps(data).encode("utf-8")
48+
return BytesIO(json_data)

tests/integration_tests/ingest/test_bulk_data.json

-74
This file was deleted.

tests/integration_tests/ingest/test_bulk_data_with_invalid_event_type.json

-42
This file was deleted.

0 commit comments

Comments
 (0)