tests: remove db modifications from individual tests
All db seeding now down in conftest
This commit is contained in:
parent
8b89595531
commit
778f1dbece
8 changed files with 160 additions and 394 deletions
|
|
@ -8,7 +8,7 @@ from sqlalchemy.orm import sessionmaker
|
|||
|
||||
from src.user.models import User
|
||||
from src.service.models import Service
|
||||
from src.organisation.models import Organisation as Org
|
||||
from src.organisation.models import Organisation as Org, OrgUsers
|
||||
from src.contact.models import Contact
|
||||
from src.iam.models import Group, Permission
|
||||
from src.auth.service import get_current_user, get_dev_user
|
||||
|
|
@ -91,13 +91,35 @@ def _seed(db):
|
|||
oidc_id="abcd-efgh-ijkl-mnop",
|
||||
)
|
||||
)
|
||||
db.add(Contact(org_id=1, email="billing@test.org", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=1, email="owner@test.org", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=1, email="security@test.org", phonenumber="07521539927"))
|
||||
db.add(
|
||||
User(
|
||||
email="user@orgone.com",
|
||||
first_name="User",
|
||||
last_name="Test",
|
||||
oidc_id="abcd-efgh-ijkl-qwer",
|
||||
)
|
||||
)
|
||||
db.add(
|
||||
User(
|
||||
email="root@orgtwo.com",
|
||||
first_name="Root",
|
||||
last_name="Test",
|
||||
oidc_id="abcd-efgh-ijkl-hjkl",
|
||||
)
|
||||
)
|
||||
db.add(Contact(org_id=1, email="billing@orgone.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=1, email="owner@orgone.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=1, email="security@orgone.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=2, email="billing@orgtwo.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=2, email="owner@orgtwo.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=2, email="security@orgtwo.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=3, email="billing@orgthree.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=3, email="owner@orgthree.com", phonenumber="07521539927"))
|
||||
db.add(Contact(org_id=3, email="security@orgthree.com", phonenumber="07521539927"))
|
||||
db.flush()
|
||||
db.add(
|
||||
Org(
|
||||
name="Test Org",
|
||||
name="Org One",
|
||||
root_user_id=1,
|
||||
billing_contact_id=1,
|
||||
owner_contact_id=2,
|
||||
|
|
@ -109,9 +131,40 @@ def _seed(db):
|
|||
},
|
||||
)
|
||||
)
|
||||
db.add(
|
||||
Org(
|
||||
name="Org Two",
|
||||
root_user_id=3,
|
||||
billing_contact_id=4,
|
||||
owner_contact_id=5,
|
||||
security_contact_id=6,
|
||||
status="approved",
|
||||
intake_questionnaire={
|
||||
"metadata": {"version": 0, "submission_date": None},
|
||||
"questions": {"question_two": "answer two"},
|
||||
},
|
||||
)
|
||||
)
|
||||
db.add(
|
||||
Org(
|
||||
name="Org Three",
|
||||
root_user_id=1,
|
||||
billing_contact_id=7,
|
||||
owner_contact_id=8,
|
||||
security_contact_id=9,
|
||||
status="partial",
|
||||
intake_questionnaire={
|
||||
"metadata": {"version": 0, "submission_date": None},
|
||||
"questions": {"question_two": "answer two"},
|
||||
},
|
||||
)
|
||||
)
|
||||
db.add(OrgUsers(org_id=1, user_id=2))
|
||||
db.add(Service(name="Test Service", api_key="123456789"))
|
||||
db.add(Permission(service_id=1, resource="test_resource", action="read"))
|
||||
db.add(Group(name="Test Group", org_id=1))
|
||||
db.add(Group(name="Org One Group", org_id=1))
|
||||
db.add(Group(name="Org Two Group", org_id=2))
|
||||
db.add(Group(name="Org One Group Two", org_id=1))
|
||||
db.flush()
|
||||
group_model = db.get(Group, 1)
|
||||
perm_model = db.get(Permission, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue