1
0
Fork 0
forked from sr2/cloud-api

tests: user accept org invite test

This commit is contained in:
Chris Milne 2026-06-24 13:20:06 +01:00
parent 28c482d8a9
commit ce6a574951

View file

@ -3,11 +3,13 @@
[DELETE]/user/ is not tested because the testing client cannot attach a body to a delete request.
"""
from datetime import timedelta, datetime, timezone
from typing import Any
import pytest
from httpx import AsyncClient
from src.utils import generate_jwt
from .conftest import generate_query_and_status, standard_test
pytestmark = [
@ -181,3 +183,33 @@ async def test_post_user_invitation_standard(
await standard_test(
default_client, method, path, auth_level, query, body, expected_data, route_data
)
@pytest.mark.anyio
async def test_post_user_invitation_accept_standard(
default_client: AsyncClient, route_data: dict[str, dict[str, Any]]
):
expiry_delta = timedelta(hours=24)
expiry = datetime.now(timezone.utc) + expiry_delta
claims = {
"email": "admin@test.com",
"org_id": 2,
"exp": expiry,
"type": "org_invite",
}
token = await generate_jwt(claims)
method = "POST"
path = "/user/invitation/accept"
auth_level = "User"
query = ""
body = {"jwt": token}
expected_data = {
"organisation": {"name": "Org Two", "id": 2},
"user": {"email": "admin@test.com", "id": 1},
}
await standard_test(
default_client, method, path, auth_level, query, body, expected_data, route_data
)