Skip to content

Commit

Permalink
Ingest test refactor (#253)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
annaCPR authored Nov 21, 2024
1 parent f549e9a commit 5061ac3
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 381 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 = "admin_backend"
version = "2.17.15"
version = "2.17.16"
description = ""
authors = ["CPR-dev-team <[email protected]>"]
packages = [{ include = "app" }, { include = "tests" }]
Expand Down
48 changes: 48 additions & 0 deletions tests/helpers/ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
import logging
from io import BytesIO
from typing import Any

logger = logging.getLogger(__name__)


default_collection = {
"import_id": "test.new.collection.0",
"title": "Test title",
"description": "Test description",
}


default_family = {
"import_id": "test.new.family.0",
"title": "Test",
"summary": "Test",
"geographies": ["South Asia"],
"category": "UNFCCC",
"metadata": {"author_type": ["Non-Party"], "author": ["Test"]},
"collections": ["test.new.collection.0"],
}


default_document = {
"import_id": "test.new.document.0",
"family_import_id": "test.new.family.0",
"metadata": {"role": ["MAIN"], "type": ["Law"]},
"variant_name": None,
"title": "",
"user_language_name": "",
}


default_event = {
"import_id": "test.new.event.0",
"family_import_id": "test.new.family.0",
"event_title": "Test",
"date": "2024-01-01",
"event_type_value": "Amended",
}


def build_json_file(data: dict[str, Any]) -> BytesIO:
json_data = json.dumps(data).encode("utf-8")
return BytesIO(json_data)
74 changes: 0 additions & 74 deletions tests/integration_tests/ingest/test_bulk_data.json

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5061ac3

Please sign in to comment.