|
1 | | -import logging |
2 | | - |
3 | | - |
4 | 1 | def test_post_item(client): |
5 | 2 | """Check if the item is added to the database""" |
6 | | - logging.debug( |
7 | | - client.post('/item', json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}) |
| 3 | + response = client.post( |
| 4 | + '/item', |
| 5 | + json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}, |
8 | 6 | ) |
| 7 | + assert response.status_code == 201 |
9 | 8 |
|
10 | 9 |
|
11 | 10 | def test_get_item(client): |
12 | 11 | """Check if the response is a dictionary""" |
13 | 12 | client.post('/item', json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}) |
14 | | - logging.debug(isinstance(client.get('/item/1').json, dict)) |
| 13 | + assert isinstance(client.get('/item/1').json, dict) |
15 | 14 |
|
16 | 15 |
|
17 | 16 | def test_get_all_items(client): |
18 | 17 | """CHeck if the response is a list""" |
19 | 18 | client.post('/item', json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}) |
20 | 19 | client.post('/item', json={'name': 'Test Item2', 'price': 15.99, 'store_id': 1}) |
21 | | - logging.debug(isinstance(client.get('/item').json, (list, dict))) |
| 20 | + assert isinstance(client.get('/item').json, list) |
22 | 21 |
|
23 | 22 |
|
24 | 23 | def test_delete_item(client): |
25 | 24 | """Check if the item is deleted from the database""" |
26 | 25 | client.post('/item', json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}) |
27 | | - client.delete('/item/1') |
28 | | - logging.debug(client.get('/item/1').status_code == 404) |
| 26 | + response = client.delete('/item/1') |
| 27 | + assert response.status_code == 200 |
29 | 28 |
|
30 | 29 |
|
31 | 30 | def test_put_item(client): |
32 | 31 | """Check if the item is updated in the database""" |
33 | | - client.post('/store', json={'store_id': 1, 'name': 'Test Store'}) |
34 | 32 | client.post('/item', json={'name': 'Test Item', 'price': 10.99, 'store_id': 1}) |
35 | | - client.put('/item/1', json={'name': 'Test Item', 'price': 15.99, 'store_id': 1}) |
36 | | - assert client.get('/item/1').json.get('price') == 15.99 |
| 33 | + response = client.put('/item/1', json={'name': 'Test Item', 'price': 15.99}) |
| 34 | + assert response.json.get('price') == 15.99 |
0 commit comments