[Tests] add new tests for oneshot type aa

This commit is contained in:
2026-07-27 17:18:04 +02:00
committed by ahtlon
parent 1efbad1db3
commit ea2a1f916d
2 changed files with 64 additions and 4 deletions

View File

@@ -2,10 +2,10 @@ import pytest
from fastapi import status
def test_create_access_auth(client, auth_headers):
def test_create_access_auth_tt(client, auth_headers):
"""Test creating a new access authorization."""
aa_data = {
"name": "New AA",
"name": "New tt_AA",
"type": "timetable",
"is_active": True,
"timetables": [
@@ -18,11 +18,44 @@ def test_create_access_auth(client, auth_headers):
assert response.status_code == 200
data = response.json()
assert data["name"] == "New AA"
assert data["name"] == "New tt_AA"
assert data["is_active"] is True
assert data["type"] == "timetable"
assert "id" in data
assert len(data["timetables"]) == 2
def test_create_access_auth_os(client, auth_headers):
"""Test creating a new access authorization with oneshot type."""
aa_data = {
"name": "New os_AA",
"type": "oneshot",
"is_active": True,
"oneshot": {
"uses": 1,
"ends_at": "2029-07-27"
}
}
response = client.post("/api/v1/aa/", json=aa_data, headers=auth_headers)
assert response.status_code == 200
data = response.json()
assert data["name"] == "New os_AA"
assert data["type"] == "oneshot"
assert data["is_active"] is True
assert "id" in data
assert data["oneshot"]["uses"] == 1
def test_create_wrong_aa_type(client, auth_headers):
"""Test creating a new access authorization with oneshot type."""
aa_data = {
"name": "New AA",
"type": "wrong",
"is_active": True,
}
response = client.post("/api/v1/aa/", json=aa_data, headers=auth_headers)
assert response.status_code == 422
def test_get_all_access_auths(client, auth_headers, test_aa_tt):
"""Test retrieving all access authorizations."""