1+ """
2+ Integration tests for the ticket registration API and database flow.
3+ """
4+
15from typing import Any
26
37import requests
@@ -12,7 +16,17 @@ def test_register_ticket_flow(
1216 base_url : str , db_connection : connection , test_username : str = "spuertaf"
1317) -> None :
1418 """
15- Tests whole ticket registration flow works as expected.
19+ Test the full ticket registration flow for a user.
20+
21+ Sends a POST request to register a ticket for the specified user, then
22+ verifies that the ticket is correctly stored in the database with
23+ expected values.
24+
25+ Args:
26+ base_url (str): Base URL of the ticket registration API.
27+ db_connection (connection): Active PostgreSQL database connection.
28+ test_username (str, optional): Username for which the ticket is registered.
29+ Defaults to "spuertaf".
1630 """
1731 headers : dict [str , str ] = {"Content-Type" : "application/json" }
1832 payload : dict [str , str ] = {"seat" : "A12" , "gate" : "G1" }
@@ -59,6 +73,17 @@ def test_register_ticket_fails_when_already_registered(
5973 base_url : str ,
6074 test_username : str = "juanperez" , # different user so tests don't collide
6175) -> None :
76+ """
77+ Test that registering the same ticket twice fails.
78+
79+ Sends a POST request to register a ticket for the user, then attempts
80+ to register the same ticket again and expects an error.
81+
82+ Args:
83+ base_url (str): Base URL of the ticket registration API.
84+ test_username (str, optional): Username for which the ticket is registered.
85+ Defaults to "juanperez".
86+ """
6287 headers : dict [str , str ] = {"Content-Type" : "application/json" }
6388 payload : dict [str , str ] = {
6489 "seat" : "B05" ,
@@ -78,6 +103,17 @@ def test_register_ticket_fails_when_already_registered(
78103
79104
80105def test_invalid_ticket_registration_error (base_url : str , test_username : str = "spuertaf" ) -> None :
106+ """
107+ Test that registering a ticket with invalid data returns an error.
108+
109+ Sends a POST request with invalid seat/gate values and expects the API
110+ to return an error code.
111+
112+ Args:
113+ base_url (str): Base URL of the ticket registration API.
114+ test_username (str, optional): Username for which the ticket is registered.
115+ Defaults to "spuertaf".
116+ """
81117 headers : dict [str , str ] = {"Content-Type" : "application/json" }
82118 payload : dict [str , str ] = {"seat" : "B05" , "gate" : "G12" }
83119 endpoint : str = f"/api/users/{ test_username } /tickets"
0 commit comments