Coverage for src/tests/api/v1/auth/schemas/test_presenters.py: 100%
11 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for testing the revoked user JSON:API resource."""
3import json
5from deepdiff import DeepDiff
6from kwai_api.v1.auth.presenters import JsonApiRevokedUserPresenter
9def test_create_revoked_user_document(make_user_account):
10 """Test creation of a user invitation JSON:API document."""
11 user_account = make_user_account()
12 user_account = user_account.revoke()
13 revoked_user_document = (
14 JsonApiRevokedUserPresenter().present(user_account).get_document()
15 )
16 json_resource = json.loads(revoked_user_document.model_dump_json())
18 expected_revoked_user_json = {
19 "data": {
20 "id": str(user_account.user.uuid),
21 "type": "revoked_users",
22 "attributes": {"revoked": True},
23 }
24 }
26 diff = DeepDiff(json_resource, expected_revoked_user_json, ignore_order=True)
27 assert not diff, f"JSON structure is not as expected: {diff}"