dump-things-server/dump_things_service/tests/test_token_endpoints.py
Christian Monch 2d15d90b8f
Some checks failed
Test execution / Test-all (push) Failing after 59s
[temp] dynamic config creation work
2026-04-15 08:35:30 +02:00

45 lines
1.3 KiB
Python

from starlette.status import HTTP_409_CONFLICT
from dump_things_service import HTTP_201_CREATED
def test_token_creation(fastapi_client_simple):
test_client, _ = fastapi_client_simple
json_record = {
'name': 'a',
'user_id': 'u_a',
'representation': '8bb6805ff10bcb1c2ca49dcd4bfef94d',
'collection_info': {
'collection_1': {
'mode': 'WRITE_COLLECTION',
'incoming_label': 'i_a'
}
}
}
# Create a token eith name 'a'
response = test_client.post(
'/tokens',
headers={'x-dumpthings-token': 'admin-1'},
json=json_record,
)
assert response.status_code == HTTP_201_CREATED
# Try to create another token eith name 'a', should result in a 4ß9-error
response = test_client.post(
'/tokens',
headers={'x-dumpthings-token': 'admin-1'},
json=json_record,
)
assert response.status_code == HTTP_409_CONFLICT
# Try to create another token eith name 'b' and the same representation
# as 'a', should result in a 4ß9-error
json_record['name'] = 'b'
response = test_client.post(
'/tokens',
headers={'x-dumpthings-token': 'admin-1'},
json=json_record,
)
assert response.status_code == HTTP_409_CONFLICT