minor: rename test client

client -> default_client

To allow for different clients. Primarily to allow different overrides for auth testing.
This commit is contained in:
Chris Milne 2026-06-03 13:54:30 +01:00
parent a907506ec1
commit 9d9ca0b907
7 changed files with 140 additions and 140 deletions

View file

@ -6,12 +6,12 @@ from httpx import AsyncClient
from src.organisation.models import Organisation, OrgUsers
from src.user.models import User
from .conftest import client
from .conftest import default_client
@pytest.mark.anyio
async def test_get_org_success(client: AsyncClient):
resp = await client.get("/org?org_id=1")
async def test_get_org_success(default_client: AsyncClient):
resp = await default_client.get("/org?org_id=1")
data = resp.json()
assert resp.status_code == 200
@ -32,15 +32,15 @@ async def test_get_org_success(client: AsyncClient):
],
)
@pytest.mark.anyio
async def test_get_org_failure(client: AsyncClient, query: str, expected_status: int):
resp = await client.get(f"/org?{query}")
async def test_get_org_failure(default_client: AsyncClient, query: str, expected_status: int):
resp = await default_client.get(f"/org?{query}")
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_post_org_success(client: AsyncClient):
resp = await client.post("/org", json={"name": "New Test Org"})
async def test_post_org_success(default_client: AsyncClient):
resp = await default_client.post("/org", json={"name": "New Test Org"})
data = resp.json()
assert resp.status_code == 201
@ -57,18 +57,18 @@ async def test_post_org_success(client: AsyncClient):
],
)
@pytest.mark.anyio
async def test_post_org_failure(client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await client.post("/org", json=body)
async def test_post_org_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await default_client.post("/org", json=body)
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_patch_org_questionnaire_partial_success(client: AsyncClient, db_session):
async def test_patch_org_questionnaire_partial_success(default_client: AsyncClient, db_session):
org_model = db_session.get(Organisation, 1)
org_model.status = "partial"
db_session.flush()
resp = await client.patch("/org/questionnaire", json={"organisation_id": 1, "intake_questionnaire": {"question_one": "new answer one", "question_two": None, "question_three": None}, "partial": True})
resp = await default_client.patch("/org/questionnaire", json={"organisation_id": 1, "intake_questionnaire": {"question_one": "new answer one", "question_two": None, "question_three": None}, "partial": True})
data = resp.json()
assert resp.status_code == 200
@ -93,18 +93,18 @@ async def test_patch_org_questionnaire_partial_success(client: AsyncClient, db_s
],
)
@pytest.mark.anyio
async def test_patch_questionnaire_partial_failure(client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await client.patch("/org/questionnaire", json=body)
async def test_patch_questionnaire_partial_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await default_client.patch("/org/questionnaire", json=body)
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_patch_org_questionnaire_submit_success(client: AsyncClient, db_session):
async def test_patch_org_questionnaire_submit_success(default_client: AsyncClient, db_session):
org_model = db_session.get(Organisation, 1)
org_model.status = "partial"
db_session.flush()
resp = await client.patch("/org/questionnaire", json={"organisation_id": 1, "intake_questionnaire": {"question_one": "new answer one", "question_two": None, "question_three": None}, "partial": False})
resp = await default_client.patch("/org/questionnaire", json={"organisation_id": 1, "intake_questionnaire": {"question_one": "new answer one", "question_two": None, "question_three": None}, "partial": False})
data = resp.json()
assert resp.status_code == 200
@ -121,8 +121,8 @@ async def test_patch_org_questionnaire_submit_success(client: AsyncClient, db_se
["partial", "submitted", "remediation", "approved", "rejected", "removed"]
)
@pytest.mark.anyio
async def test_patch_org_status_success(client: AsyncClient, status: str):
resp = await client.patch("/org/status", json={"organisation_id": 1, "status": status})
async def test_patch_org_status_success(default_client: AsyncClient, status: str):
resp = await default_client.patch("/org/status", json={"organisation_id": 1, "status": status})
data = resp.json()
assert resp.status_code == 200
@ -142,15 +142,15 @@ async def test_patch_org_status_success(client: AsyncClient, status: str):
],
)
@pytest.mark.anyio
async def test_patch_org_status_failure(client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await client.patch("/org/status", json=body)
async def test_patch_org_status_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await default_client.patch("/org/status", json=body)
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_get_org_users_success(client: AsyncClient):
resp = await client.get("/org/users?org_id=1")
async def test_get_org_users_success(default_client: AsyncClient):
resp = await default_client.get("/org/users?org_id=1")
data = resp.json()
assert resp.status_code == 200
@ -173,18 +173,18 @@ async def test_get_org_users_success(client: AsyncClient):
],
)
@pytest.mark.anyio
async def test_get_org_users_failure(client: AsyncClient, query: str, expected_status: int):
resp = await client.get(f"/org/users?{query}")
async def test_get_org_users_failure(default_client: AsyncClient, query: str, expected_status: int):
resp = await default_client.get(f"/org/users?{query}")
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_post_org_user_success(client: AsyncClient, db_session):
async def test_post_org_user_success(default_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()
resp = await client.post("/org/user", json={"organisation_id": 1, "user_id": 2})
resp = await default_client.post("/org/user", json={"organisation_id": 1, "user_id": 2})
data = resp.json()
assert resp.status_code == 200
@ -204,23 +204,23 @@ async def test_post_org_user_success(client: AsyncClient, db_session):
],
)
@pytest.mark.anyio
async def test_post_org_failure(client: AsyncClient, body: dict[str, str], expected_status: int, db_session):
async def test_post_org_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int, 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()
resp = await client.post("/org/user", json=body)
resp = await default_client.post("/org/user", json=body)
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_patch_org_root_user_success(client: AsyncClient, db_session):
async def test_patch_org_root_user_success(default_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()
db_session.add(OrgUsers(org_id=1, user_id=2))
db_session.flush()
resp = await client.patch("/org/root_user", json={"organisation_id": 1, "user_id": 2})
resp = await default_client.patch("/org/root_user", json={"organisation_id": 1, "user_id": 2})
data = resp.json()
assert resp.status_code == 200
@ -241,20 +241,20 @@ async def test_patch_org_root_user_success(client: AsyncClient, db_session):
],
)
@pytest.mark.anyio
async def test_patch_root_user_failure(client: AsyncClient, body: dict[str, str], expected_status: int, db_session):
async def test_patch_root_user_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int, 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()
db_session.add(OrgUsers(org_id=1, user_id=2))
db_session.flush()
resp = await client.patch("/org/root_user", json=body)
resp = await default_client.patch("/org/root_user", json=body)
assert resp.status_code == expected_status
@pytest.mark.anyio
async def test_get_org_groups_success(client: AsyncClient):
resp = await client.get("/org/groups?org_id=1")
async def test_get_org_groups_success(default_client: AsyncClient):
resp = await default_client.get("/org/groups?org_id=1")
data = resp.json()
assert resp.status_code == 200
@ -272,8 +272,8 @@ async def test_get_org_groups_success(client: AsyncClient):
],
)
@pytest.mark.anyio
async def test_get_org_groups_failure(client: AsyncClient, query: str, expected_status: int):
resp = await client.get(f"/org/groups?{query}")
async def test_get_org_groups_failure(default_client: AsyncClient, query: str, expected_status: int):
resp = await default_client.get(f"/org/groups?{query}")
assert resp.status_code == expected_status
@ -283,8 +283,8 @@ async def test_get_org_groups_failure(client: AsyncClient, query: str, expected_
["billing", "security", "owner"]
)
@pytest.mark.anyio
async def test_get_org_contact_success(client: AsyncClient, contact_type: str):
resp = await client.get(f"/org/contact?org_id=1&contact_type={contact_type}")
async def test_get_org_contact_success(default_client: AsyncClient, contact_type: str):
resp = await default_client.get(f"/org/contact?org_id=1&contact_type={contact_type}")
data = resp.json()
assert resp.status_code == 200
@ -326,8 +326,8 @@ async def test_get_org_contact_success(client: AsyncClient, contact_type: str):
],
)
@pytest.mark.anyio
async def test_get_org_contact_failure(client: AsyncClient, query: str, expected_status: int):
resp = await client.get(f"/org/contact?{query}")
async def test_get_org_contact_failure(default_client: AsyncClient, query: str, expected_status: int):
resp = await default_client.get(f"/org/contact?{query}")
assert resp.status_code == expected_status
@ -350,8 +350,8 @@ async def test_get_org_contact_failure(client: AsyncClient, query: str, expected
]
)
@pytest.mark.anyio
async def test_patch_org_contact_success(client: AsyncClient, key: str, value: str):
resp = await client.patch("/org/contact", json={"organisation_id": 1, "contact_type": "billing", key: value})
async def test_patch_org_contact_success(default_client: AsyncClient, key: str, value: str):
resp = await default_client.patch("/org/contact", json={"organisation_id": 1, "contact_type": "billing", key: value})
data = resp.json()
assert resp.status_code == 200
@ -376,7 +376,7 @@ async def test_patch_org_contact_success(client: AsyncClient, key: str, value: s
],
)
@pytest.mark.anyio
async def test_patch_org_status_failure(client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await client.patch("/org/contact", json=body)
async def test_patch_org_status_failure(default_client: AsyncClient, body: dict[str, str], expected_status: int):
resp = await default_client.patch("/org/contact", json=body)
assert resp.status_code == expected_status