tests: user accept org invite test
This commit is contained in:
parent
28c482d8a9
commit
ce6a574951
1 changed files with 32 additions and 0 deletions
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue