@@ -30,25 +30,26 @@ def test_headers_validation():
3030 with allure .step ("Send GET request to users endpoint" ):
3131 url = f"{ BASE_URL } /users?page=1"
3232 response = requests .get (url , headers = get_headers ())
33-
33+
3434 with allure .step ("Verify response status is 200" ):
3535 assert response .status_code == 200
36-
36+
3737 with allure .step ("Validate Content-Type header" ):
3838 assert response .headers ["Content-Type" ].startswith ("application/json" )
39-
39+
4040 with allure .step ("Validate response headers are present" ):
4141 # Check for Content-Type (always present)
4242 assert "Content-Type" in response .headers
43-
43+
4444 # Check for either Content-Length or Transfer-Encoding (both are valid)
4545 has_content_length = "Content-Length" in response .headers
4646 has_transfer_encoding = "Transfer-Encoding" in response .headers
47- assert has_content_length or has_transfer_encoding , "Either Content-Length or Transfer-Encoding should be present"
48-
47+ assert has_content_length or has_transfer_encoding , \
48+ "Either Content-Length or Transfer-Encoding should be present"
49+
4950 # Validate Date header is present
5051 assert "Date" in response .headers
51-
52+
5253 with allure .step ("Attach headers to report" ):
5354 headers_info = dict (response .headers )
5455 allure .attach (str (headers_info ), "Response Headers" , allure .attachment_type .TEXT )
@@ -68,23 +69,23 @@ def test_user_list_schema_validation():
6869 with allure .step ("Send GET request to user list endpoint" ):
6970 url = f"{ BASE_URL } /users?page=1"
7071 response = requests .get (url , headers = get_headers ())
71-
72+
7273 with allure .step ("Verify response status is 200" ):
7374 assert response .status_code == 200
74-
75+
7576 with allure .step ("Load and apply schema validation" ):
7677 data = response .json ()
7778 schema = load_schema ("user_list_schema.json" )
7879 validate (instance = data , schema = schema )
79-
80+
8081 with allure .step ("Validate specific data structure" ):
8182 assert "data" in data
8283 assert "page" in data
8384 assert "per_page" in data
8485 assert "total" in data
8586 assert "total_pages" in data
8687 assert isinstance (data ["data" ], list )
87-
88+
8889 with allure .step ("Validate user objects in data array" ):
8990 for user in data ["data" ]:
9091 assert "id" in user
@@ -95,7 +96,7 @@ def test_user_list_schema_validation():
9596 assert isinstance (user ["id" ], int )
9697 assert isinstance (user ["email" ], str )
9798 assert "@" in user ["email" ] # Basic email validation
98-
99+
99100 with allure .step ("Attach response for verification" ):
100101 allure .attach (response .text , "User List Response" , allure .attachment_type .JSON )
101102
@@ -114,15 +115,15 @@ def test_single_user_schema_validation():
114115 with allure .step ("Send GET request to single user endpoint" ):
115116 url = f"{ BASE_URL } /users/2"
116117 response = requests .get (url , headers = get_headers ())
117-
118+
118119 with allure .step ("Verify response status is 200" ):
119120 assert response .status_code == 200
120-
121+
121122 with allure .step ("Load and apply schema validation" ):
122123 data = response .json ()
123124 schema = load_schema ("single_user_schema.json" )
124125 validate (instance = data , schema = schema )
125-
126+
126127 with allure .step ("Validate user data structure" ):
127128 assert "data" in data
128129 assert "support" in data
@@ -132,12 +133,12 @@ def test_single_user_schema_validation():
132133 assert "first_name" in user_data
133134 assert "last_name" in user_data
134135 assert "avatar" in user_data
135-
136+
136137 with allure .step ("Validate support information" ):
137138 support = data ["support" ]
138139 assert "url" in support
139140 assert "text" in support
140-
141+
141142 with allure .step ("Attach response for verification" ):
142143 allure .attach (response .text , "Single User Response" , allure .attachment_type .JSON )
143144
@@ -157,15 +158,16 @@ def test_response_time_validation(endpoint):
157158 with allure .step (f"Send GET request to { endpoint } " ):
158159 url = f"{ BASE_URL } { endpoint } "
159160 response = requests .get (url , headers = get_headers ())
160-
161+
161162 with allure .step ("Verify response status is 200" ):
162163 assert response .status_code == 200
163-
164+
164165 with allure .step ("Validate response time is acceptable" ):
165166 response_time = response .elapsed .total_seconds ()
166167 # Expecting response within 5 seconds (configurable)
167168 max_response_time = config .get ("timeout_seconds" , 5 )
168- assert response_time < max_response_time , f"Response time { response_time } s exceeded limit of { max_response_time } s"
169-
169+ assert response_time < max_response_time , \
170+ f"Response time { response_time } s exceeded limit of { max_response_time } s"
171+
170172 with allure .step ("Attach performance metrics" ):
171173 allure .attach (f"Response Time: { response_time :.3f} seconds" , "Performance Metrics" , allure .attachment_type .TEXT )
0 commit comments