-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/pdct 1553 fix query for muli geography (#366)
* Add a test for get_family_document_and_context * Add tests for multi geog * Turn test green * bump version * update geo subquery * make test more data driven * use a different geo id
- Loading branch information
1 parent
c0c28f7
commit a78a4c0
Showing
5 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "navigator_backend" | ||
version = "1.17.2" | ||
version = "1.17.3" | ||
description = "" | ||
authors = ["CPR-dev-team <[email protected]>"] | ||
packages = [{ include = "app" }, { include = "tests" }] | ||
|
53 changes: 53 additions & 0 deletions
53
tests/unit/app/db/crud/test_get_family_document_and_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from typing import Dict | ||
|
||
from db_client.models.dfce import FamilyDocument, FamilyGeography | ||
from sqlalchemy.orm import Session | ||
|
||
from app.api.api_v1.schemas.document import FamilyDocumentWithContextResponse | ||
from app.db.crud.document import get_family_document_and_context | ||
from tests.non_search.setup_helpers import setup_with_documents_large_with_families | ||
|
||
|
||
def test_get_family_document_and_context( | ||
documents_large: list[Dict], | ||
data_db: Session, | ||
): | ||
setup_with_documents_large_with_families(documents_large, data_db) | ||
doc = ( | ||
data_db.query(FamilyDocument) | ||
.filter(FamilyDocument.import_id == "CCLW.document.i00000192.n0000") | ||
.one() | ||
) | ||
|
||
response: FamilyDocumentWithContextResponse = get_family_document_and_context( | ||
data_db, doc.import_id | ||
) | ||
|
||
assert response.family.import_id == doc.family_import_id | ||
assert response.document.import_id == doc.import_id | ||
|
||
|
||
def test_get_family_document_and_context_extra_geog( | ||
documents_large: list[Dict], | ||
data_db: Session, | ||
): | ||
setup_with_documents_large_with_families(documents_large, data_db) | ||
doc = ( | ||
data_db.query(FamilyDocument) | ||
.filter(FamilyDocument.import_id == "CCLW.document.i00000192.n0000") | ||
.one() | ||
) | ||
# add an extra geography | ||
data_db.add( | ||
FamilyGeography( | ||
family_import_id=doc.family_import_id, | ||
geography_id=17, | ||
) | ||
) | ||
data_db.commit() | ||
response: FamilyDocumentWithContextResponse = get_family_document_and_context( | ||
data_db, doc.import_id | ||
) | ||
|
||
assert response.family.import_id == doc.family_import_id | ||
assert response.document.import_id == doc.import_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters