Skip to content

Commit

Permalink
Feature/pdct 1095 move document type to taxonomy (#175)
Browse files Browse the repository at this point in the history
* Bump to 2.10.11

* Bump db_client to 3.8.7 - dev commit

* Update document helpers

* Add type to metadata in tests & use helper function in test_update

* Fix test

* Bump dbclient to 3.8.6

* Bump dbclient to 3.8.7

* Fix test

* Populate doc type in test setup

* Bump to 2.10.12
  • Loading branch information
katybaulch authored Jul 17, 2024
1 parent 9a61abd commit 63a3f9b
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 130 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "admin_backend"
version = "2.10.11"
version = "2.10.12"
description = ""
authors = ["CPR-dev-team <[email protected]>"]
packages = [{ include = "app" }, { include = "tests" }]
Expand Down Expand Up @@ -29,7 +29,7 @@ boto3 = "^1.28.46"
moto = "^4.2.2"
types-sqlalchemy = "^1.4.53.38"
urllib3 = "^1.26.17"
db-client = { git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.8.6" }
db-client = { git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.8.7" }

[tool.poetry.dev-dependencies]
pre-commit = "^2.17.0"
Expand Down
17 changes: 12 additions & 5 deletions tests/helpers/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create_document_create_dto(
if source_url is not None:
source_url = cast(AnyHttpUrl, source_url)
if metadata is None:
metadata = {"role": ["MAIN"]}
metadata = {"role": ["MAIN"], "type": ["Law"]}
return DocumentCreateDTO(
family_import_id=family_import_id,
variant_name=variant_name,
Expand All @@ -35,16 +35,23 @@ def create_document_write_dto(
title: str = "title",
variant_name: Optional[str] = "Original Language",
metadata: Optional[Json] = None,
source_url: Optional[str] = "http://update_source",
user_language_name: Optional[str] = "English",
) -> DocumentWriteDTO:

if metadata is None:
metadata = {"role": ["MAIN"]}
metadata = {"role": ["MAIN"], "type": ["Law"]}
return DocumentWriteDTO(
variant_name=variant_name,
type="Law",
metadata=metadata,
title=title,
source_url=cast(AnyHttpUrl, "http://source"),
user_language_name="Ghotuo",
source_url=(
cast(AnyHttpUrl, "http://update_source")
if isinstance(source_url, str)
else None
),
user_language_name=user_language_name,
)


Expand All @@ -57,7 +64,7 @@ def create_document_read_dto(
corpus_type: Optional[str] = None,
) -> DocumentReadDTO:
if metadata is None:
metadata = {"role": ["MAIN"]}
metadata = {"role": ["MAIN"], "type": ["Law"]}
if corpus_type is None:
corpus_type = "Laws and Policies"
return DocumentReadDTO(
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/document/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_create_document_when_invalid_metadata_cclw(
assert response.status_code == status.HTTP_400_BAD_REQUEST
data = response.json()

key_text = "{'role'}"
key_text = "{'role', 'type'}"

expected_message = "Metadata validation failed: "
expected_missing_message = f"Missing metadata keys: {key_text}"
Expand Down Expand Up @@ -416,7 +416,7 @@ def test_create_document_when_invalid_metadata_unfccc(
assert response.status_code == status.HTTP_400_BAD_REQUEST
data = response.json()

key_text = "{'role'}"
key_text = "{'role', 'type'}"

expected_message = "Metadata validation failed: "
expected_missing_message = f"Missing metadata keys: {key_text}"
Expand Down
Loading

0 comments on commit 63a3f9b

Please sign in to comment.