Skip to content

Commit e4148fa

Browse files
committed
add schema test for user albums
1 parent aacea8e commit e4148fa

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

api_tests/Integration_tests/test_user_alboms.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,21 @@ def test_get_user_albom_number_2(api):
1414
assert data[2]['userId'] == 1,"error in user id,expected 3"
1515
assert data[2]['id'] == 3,"error is user id,expected 3"
1616
assert data[2]['title'] == "omnis laborum odio"
17+
18+
def test_user_albums_schema(api):
19+
"""
20+
Validates that each album in the response has the correct schema:
21+
- id: int
22+
- title: str
23+
- userId: int
24+
"""
25+
response = api.get("users/1/albums")
26+
assert response.status_code == ApiHttpConstants.OK
27+
data = response.json()
28+
assert isinstance(data, list), f"Expected list, got {type(data)}"
29+
for album in data:
30+
assert isinstance(album, dict), f"Album is not a dict: {album}"
31+
assert set(album.keys()) == {"id", "title", "userId"}, f"Unexpected keys: {album.keys()}"
32+
assert isinstance(album["id"], int), f"id is not int: {album['id']}"
33+
assert isinstance(album["title"], str), f"title is not str: {album['title']}"
34+
assert isinstance(album["userId"], int), f"userId is not int: {album['userId']}"

0 commit comments

Comments
 (0)