Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDCT 998/ensure new documents have relationships in old and new schema #107

Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f50713a
Upgrade dbclient to v3.2.1 & remove ruff config
katybaulch Mar 25, 2024
89193fd
Merge branch 'main' into PDCT-998/ensure-new-documents-have-relations…
katybaulch Mar 25, 2024
d0e4dcd
Configure pyright to work with pyenv in makefile
katybaulch Mar 25, 2024
92fe7a1
Add pyrightconfig to gitignore & add trunk ignores
katybaulch Mar 25, 2024
1b2459f
Add ruff config for trunk
katybaulch Mar 25, 2024
bb46706
Populate old and new schema for new families.
katybaulch Mar 25, 2024
5113a3b
Don't add corpus type on family create.
katybaulch Mar 25, 2024
b32d746
Update blank.sql with alembic version 0032 schema
katybaulch Mar 26, 2024
e12b288
update tests
diversemix Mar 26, 2024
ab784b0
fix final tests
diversemix Mar 26, 2024
c7d52fa
Fix formatting trunk issues
diversemix Mar 26, 2024
1254c41
fix unbound vars
diversemix Mar 26, 2024
d7f8429
fix bad test data
diversemix Mar 26, 2024
09ddf91
update test for idempotency
diversemix Mar 26, 2024
7df9dea
Fix script to install pyenv-pyright if not in expected location
katybaulch Mar 26, 2024
2090710
Formatting fix
katybaulch Mar 26, 2024
72460b7
Add test for checking new schema is also populated on fam create
katybaulch Mar 26, 2024
0904303
Merge branch 'main' into PDCT-998/ensure-new-documents-have-relations…
katybaulch Mar 26, 2024
fb50ba9
Use [[ ]] and prevent hiding return of dir_exists command
katybaulch Mar 26, 2024
c0dc4ee
Check old schema 'organisation_id' on family is still populated
katybaulch Mar 26, 2024
27001ae
Check org_id not None
katybaulch Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions integration_tests/family/test_create.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Optional

from db_client.models.dfce.collection import CollectionFamily
from db_client.models.dfce.family import Family, Slug
from db_client.models.dfce.family import Family, FamilyCorpus, FamilyOrganisation, Slug
from db_client.models.dfce.metadata import FamilyMetadata
from db_client.models.organisation.corpus import Corpus
from fastapi import status
from fastapi.testclient import TestClient
from sqlalchemy.orm import Session
Expand All @@ -24,28 +25,47 @@ def test_create_family(client: TestClient, data_db: Session, user_header_token):
"/api/v1/families", json=new_family.model_dump(), headers=user_header_token
)
assert response.status_code == status.HTTP_201_CREATED
import_id = response.json()
assert import_id == "CCLW.family.i00000001.n0000"
actual_family = data_db.query(Family).filter(Family.import_id == import_id).one()
expected_import_id = "CCLW.family.i00000001.n0000"
assert response.json() == expected_import_id
actual_family = (
data_db.query(Family).filter(Family.import_id == expected_import_id).one()
)

assert actual_family.title == "Title"
diversemix marked this conversation as resolved.
Show resolved Hide resolved
assert actual_family.description == "test test test"
metadata = (
data_db.query(FamilyMetadata)
.filter(FamilyMetadata.family_import_id == import_id)
.filter(FamilyMetadata.family_import_id == expected_import_id)
.one()
)
assert metadata.value is not None
assert metadata.value == test_meta

db_collection: Optional[list[CollectionFamily]] = (
data_db.query(CollectionFamily)
.filter(CollectionFamily.family_import_id == "CCLW.family.i00000001.n0000")
.filter(CollectionFamily.family_import_id == expected_import_id)
.all()
)
assert db_collection is not None
assert len(db_collection) == 1
assert db_collection[0].collection_import_id == "C.0.0.3"

# New schema tests.
fc = (
data_db.query(FamilyCorpus)
.filter(FamilyCorpus.family_import_id == expected_import_id)
.all()
)
assert len(fc) == 1
assert fc[-1].corpus_import_id is not None
org_id = (
data_db.query(FamilyOrganisation.organisation_id)
.filter(FamilyOrganisation.family_import_id == expected_import_id)
.scalar()
)
corpus = data_db.query(Corpus).filter(Corpus.organisation_id == org_id).one()
assert fc[-1].corpus_import_id == corpus.import_id


def test_create_family_when_not_authorised(client: TestClient, data_db: Session):
setup_db(data_db)
Expand Down