fix: ty compliant & issues from change to mapped columns
This commit is contained in:
parent
55927946c7
commit
58e7ae6c5c
31 changed files with 271 additions and 254 deletions
|
|
@ -15,7 +15,7 @@ from src.auth.service import get_current_user, get_dev_user
|
|||
from src.auth.dependencies import empty_su_list, get_super_admin_list, testing_su_list
|
||||
from src.main import app # inited FastAPI app
|
||||
from src.database import engine, get_db
|
||||
from models import CustomBase
|
||||
from src.models import CustomBase
|
||||
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
|
|
|
|||
|
|
@ -165,9 +165,7 @@ async def test_post_user_invitation_auth_approval(no_su_client: AsyncClient):
|
|||
|
||||
@pytest.mark.anyio
|
||||
async def test_delete_group_permissions_auth_approval(no_su_client: AsyncClient):
|
||||
resp = await no_su_client.delete(
|
||||
"/iam/group/permission?org_id=3&group_id=1&perm_id=1"
|
||||
)
|
||||
resp = await no_su_client.delete("/iam/group/permission?org_id=3&group_id=1&perm_id=1")
|
||||
|
||||
assert resp.status_code != 422
|
||||
assert "has not been approved." in resp.json()["detail"]
|
||||
|
|
|
|||
|
|
@ -69,9 +69,7 @@ async def test_post_perm_auth_su(no_su_client: AsyncClient):
|
|||
|
||||
@pytest.mark.anyio
|
||||
async def test_post_org_user_auth_su(no_su_client: AsyncClient):
|
||||
resp = await no_su_client.post(
|
||||
"/org/user", json={"organisation_id": 1, "user_id": 2}
|
||||
)
|
||||
resp = await no_su_client.post("/org/user", json={"organisation_id": 1, "user_id": 2})
|
||||
assert resp.status_code != 422
|
||||
assert resp.status_code == 403
|
||||
assert "Must be super admin" in resp.json()["detail"]
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ async def test_post_act_on_resource_endpoint_success(default_client: AsyncClient
|
|||
"Authorization": "Bearer not_checked_when_auth_is_disabled",
|
||||
"X-API-Key": "123456789",
|
||||
}
|
||||
resp = await default_client.post(
|
||||
"/iam/can_act_on_resource", json=body, headers=headers
|
||||
)
|
||||
resp = await default_client.post("/iam/can_act_on_resource", json=body, headers=headers)
|
||||
data = resp.json()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
|
@ -56,9 +54,7 @@ async def test_act_on_resource_wrong_key(
|
|||
"Authorization": "Bearer not_checked_when_auth_is_disabled",
|
||||
"X-API-Key": api_key,
|
||||
}
|
||||
resp = await default_client.post(
|
||||
"/iam/can_act_on_resource", json=body, headers=headers
|
||||
)
|
||||
resp = await default_client.post("/iam/can_act_on_resource", json=body, headers=headers)
|
||||
data = resp.json()
|
||||
|
||||
assert resp.status_code == 401
|
||||
|
|
@ -110,9 +106,7 @@ async def test_act_on_resource_endpoint_status_checks(
|
|||
"Authorization": "Bearer not_checked_when_auth_is_disabled",
|
||||
"X-API-Key": "123456789",
|
||||
}
|
||||
resp = await default_client.post(
|
||||
"/iam/can_act_on_resource", json=body, headers=headers
|
||||
)
|
||||
resp = await default_client.post("/iam/can_act_on_resource", json=body, headers=headers)
|
||||
|
||||
assert resp.status_code == expected_status
|
||||
|
||||
|
|
@ -143,9 +137,7 @@ async def test_act_on_resource_logic(
|
|||
"Authorization": "Bearer not_checked_when_auth_is_disabled",
|
||||
"X-API-Key": "123456789",
|
||||
}
|
||||
resp = await default_client.post(
|
||||
"/iam/can_act_on_resource", json=body, headers=headers
|
||||
)
|
||||
resp = await default_client.post("/iam/can_act_on_resource", json=body, headers=headers)
|
||||
data = resp.json()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
|
@ -414,9 +406,7 @@ async def test_get_permissions_success(default_client: AsyncClient):
|
|||
assert permission["action"] == "read"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["org_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||
@pytest.mark.anyio
|
||||
async def test_get_permissions_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
|
|
|
|||
|
|
@ -35,9 +35,7 @@ async def test_get_org_success(default_client: AsyncClient):
|
|||
assert org["security_contact"]["email"] == "security@orgone.com"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["org_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||
@pytest.mark.anyio
|
||||
async def test_get_org_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
|
|
@ -60,7 +58,6 @@ async def test_post_org_success(default_client: AsyncClient):
|
|||
@pytest.mark.parametrize(
|
||||
"body, expected_status",
|
||||
[
|
||||
({"name": "Org One"}, 409),
|
||||
({"name": 42}, 422),
|
||||
({}, 422),
|
||||
({"name": "New Test Org", "intake_questionnaire": {"question_one": 42}}, 422),
|
||||
|
|
@ -229,9 +226,7 @@ async def test_get_org_users_success(default_client: AsyncClient):
|
|||
assert data["organisation"]["id"] == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["org_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||
@pytest.mark.anyio
|
||||
async def test_get_org_users_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
|
|
@ -243,9 +238,7 @@ async def test_get_org_users_status_checks(
|
|||
|
||||
@pytest.mark.anyio
|
||||
async def test_post_org_user_success(default_client: AsyncClient):
|
||||
resp = await default_client.post(
|
||||
"/org/user", json={"organisation_id": 1, "user_id": 3}
|
||||
)
|
||||
resp = await default_client.post("/org/user", json={"organisation_id": 1, "user_id": 3})
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
||||
|
|
@ -258,9 +251,7 @@ async def test_post_org_user_success(default_client: AsyncClient):
|
|||
|
||||
assert "users" in data
|
||||
assert isinstance(data["users"], list)
|
||||
assert (
|
||||
len([user for user in data["users"] if user["email"] == "root@orgtwo.com"]) == 1
|
||||
)
|
||||
assert len([user for user in data["users"] if user["email"] == "root@orgtwo.com"]) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -348,9 +339,7 @@ async def test_get_org_groups_success(default_client: AsyncClient):
|
|||
assert group["name"] == "Org One Group"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["org_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||
@pytest.mark.anyio
|
||||
async def test_get_org_groups_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
|
|
@ -363,9 +352,7 @@ async def test_get_org_groups_status_checks(
|
|||
@pytest.mark.parametrize("contact_type", ["billing", "security", "owner"])
|
||||
@pytest.mark.anyio
|
||||
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}"
|
||||
)
|
||||
resp = await default_client.get(f"/org/contact?org_id=1&contact_type={contact_type}")
|
||||
data = resp.json()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
|
@ -437,9 +424,7 @@ async def test_get_org_contact_status_checks(
|
|||
],
|
||||
)
|
||||
@pytest.mark.anyio
|
||||
async def test_patch_org_contact_success(
|
||||
default_client: AsyncClient, key: str, value: str
|
||||
):
|
||||
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},
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ async def test_get_services_success(default_client: AsyncClient):
|
|||
assert data["services"][0]["name"] == "Test Service"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["org_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["org_id"]))
|
||||
@pytest.mark.anyio
|
||||
async def test_get_services_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
|
|
@ -49,9 +47,7 @@ async def test_post_service_success(default_client: AsyncClient):
|
|||
assert isinstance(data["service"]["api_key"], str)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"body, expected_status", generate_body_and_status({"name": "str"})
|
||||
)
|
||||
@pytest.mark.parametrize("body, expected_status", generate_body_and_status({"name": "str"}))
|
||||
@pytest.mark.anyio
|
||||
async def test_post_service_status_checks(
|
||||
default_client: AsyncClient, body: dict[str, str], expected_status: int
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ async def test_get_user_success(default_client: AsyncClient):
|
|||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.parametrize(
|
||||
"query, expected_status", generate_query_and_status(["user_id"])
|
||||
)
|
||||
@pytest.mark.parametrize("query, expected_status", generate_query_and_status(["user_id"]))
|
||||
async def test_get_user_status_checks(
|
||||
default_client: AsyncClient, query: str, expected_status: int
|
||||
):
|
||||
|
|
@ -184,10 +182,8 @@ async def test_get_self_orgs_dynamic(default_client: AsyncClient):
|
|||
|
||||
route = next(
|
||||
route
|
||||
for route in default_client._transport.app.routes
|
||||
if isinstance(route, APIRoute)
|
||||
and path in route.path
|
||||
and method in route.methods
|
||||
for route in default_client._transport.app.routes # ty:ignore[unresolved-attribute]
|
||||
if isinstance(route, APIRoute) and path in route.path and method in route.methods
|
||||
)
|
||||
|
||||
assert resp.status_code == route.status_code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue