1
0
Fork 0
forked from sr2/cloud-api

tests: remove db modifications from individual tests

All db seeding now down in conftest
This commit is contained in:
Chris Milne 2026-06-12 11:29:42 +01:00
parent 8b89595531
commit 778f1dbece
8 changed files with 160 additions and 394 deletions

View file

@ -6,42 +6,12 @@ DELETE endpoints are not tested
import pytest
from httpx import AsyncClient
from src.organisation.models import Organisation as Org
from src.user.models import User
from src.iam.models import Group
pytestmark = [
pytest.mark.auth,
pytest.mark.root_user,
]
@pytest.fixture(autouse=True)
def add_second_org(db_session):
db_session.add(
User(
email="admin@test.org",
first_name="Admin",
last_name="Test",
oidc_id="abcd-efgh-ijkl-4321",
)
)
db_session.flush()
db_session.add(
Org(
name="Test Org Two",
root_user_id=2,
billing_contact_id=1,
owner_contact_id=2,
security_contact_id=3,
status="approved",
intake_questionnaire={},
)
)
db_session.flush()
@pytest.mark.anyio
async def test_get_org_auth_root(no_su_client: AsyncClient):
resp = await no_su_client.get("/org?org_id=2")
@ -143,11 +113,7 @@ async def test_post_iam_group_auth_root(no_su_client: AsyncClient):
@pytest.mark.anyio
async def test_put_iam_group_permission_auth_root(
no_su_client: AsyncClient, db_session
):
db_session.add(Group(name="Test Group Two", org_id=2))
db_session.flush()
async def test_put_iam_group_permission_auth_root(no_su_client: AsyncClient):
resp = await no_su_client.put(
"/iam/group/permission",
json={"permission_id": 1, "group_id": 2, "organisation_id": 2},
@ -158,17 +124,9 @@ async def test_put_iam_group_permission_auth_root(
@pytest.mark.anyio
async def test_put_iam_group_user_auth_root(no_su_client: AsyncClient, db_session):
db_session.add(
User(
email="user@test.org",
first_name="User",
last_name="Test",
oidc_id="abcd-efgh-ijkl-1234",
)
)
db_session.flush()
async def test_put_iam_group_user_auth_root(
no_su_client: AsyncClient,
):
resp = await no_su_client.put(
"/iam/group/user", json={"user_id": 2, "group_id": 1, "organisation_id": 2}
)