1- from python_picnic_api2 import PicnicAPI
2- from dotenv import load_dotenv
31import os
4- import pytest
52import time
63
4+ import pytest
5+ from dotenv import load_dotenv
6+
7+ from python_picnic_api2 import PicnicAPI
8+
79load_dotenv ()
810
911username = os .getenv ("USERNAME" )
@@ -28,23 +30,23 @@ def _get_amount(cart: dict, product_id: str):
2830def test_get_user ():
2931 response = picnic .get_user ()
3032 assert isinstance (response , dict )
31- assert "contact_email" in response . keys ()
33+ assert "contact_email" in response
3234 assert response ["contact_email" ] == username
3335
3436
3537def test_search ():
3638 response = picnic .search ("kaffee" )
3739 assert isinstance (response , list )
3840 assert isinstance (response [0 ], dict )
39- assert "items" in response [0 ]. keys ()
41+ assert "items" in response [0 ]
4042 assert isinstance (response [0 ]["items" ], list )
4143 assert "id" in response [0 ]["items" ][0 ]
4244
4345
4446def test_get_article ():
4547 response = picnic .get_article ("s1018620" )
4648 assert isinstance (response , dict )
47- assert "id" in response . keys ()
49+ assert "id" in response
4850 assert response ["id" ] == "s1018620"
4951 assert response ["name" ] == "Gut&Günstig H-Milch 3,5%"
5052
@@ -57,7 +59,7 @@ def test_get_article_with_category_name():
5759def test_get_cart ():
5860 response = picnic .get_cart ()
5961 assert isinstance (response , dict )
60- assert "id" in response . keys ()
62+ assert "id" in response
6163 assert response ["id" ] == "shopping_cart"
6264
6365
@@ -67,9 +69,8 @@ def test_add_product():
6769 response = picnic .add_product ("s1018620" , count = 2 )
6870
6971 assert isinstance (response , dict )
70- assert "items" in response .keys ()
71- assert any (
72- item ["id" ] == "s1018620" for item in response ["items" ][0 ]["items" ])
72+ assert "items" in response
73+ assert any (item ["id" ] == "s1018620" for item in response ["items" ][0 ]["items" ])
7374 assert _get_amount (response , "s1018620" ) == 2
7475
7576
@@ -83,7 +84,7 @@ def test_remove_product():
8384 amount = _get_amount (response , "s1018620" )
8485
8586 assert isinstance (response , dict )
86- assert "items" in response . keys ()
87+ assert "items" in response
8788 assert amount == 1
8889
8990
@@ -96,14 +97,14 @@ def test_clear_cart():
9697 response = picnic .clear_cart ()
9798
9899 assert isinstance (response , dict )
99- assert "items" in response . keys ()
100+ assert "items" in response
100101 assert len (response ["items" ]) == 0
101102
102103
103104def test_get_delivery_slots ():
104105 response = picnic .get_delivery_slots ()
105106 assert isinstance (response , dict )
106- assert "delivery_slots" in response . keys ()
107+ assert "delivery_slots" in response
107108 assert isinstance (response ["delivery_slots" ], list )
108109
109110
@@ -143,4 +144,4 @@ def test_print_categories(capsys):
143144 assert isinstance (captured .out , str )
144145
145146
146- # TO DO : add test for re-logging
147+ # TODO : add test for re-logging
0 commit comments