11######################################################################
2- # Copyright 2016, 2023 John J. Rofrano. All Rights Reserved.
2+ # Copyright 2016, 2024 John J. Rofrano. All Rights Reserved.
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
2323 https://selenium-python.readthedocs.io/waits.html
2424"""
2525import requests
26- from behave import given
26+ from compare3 import expect
27+ from behave import given # pylint: disable=no-name-in-module
2728
2829# HTTP Return Codes
2930HTTP_200_OK = 200
3031HTTP_201_CREATED = 201
3132HTTP_204_NO_CONTENT = 204
3233
34+ WAIT_TIMEOUT = 60
35+
36+
3337@given ('the following pets' )
3438def step_impl (context ):
3539 """ Delete all Pets and load new ones """
3640
37- # List all of the pets and delete them one by one
41+ # Get a list all of the pets
3842 rest_endpoint = f"{ context .base_url } /pets"
39- context .resp = requests .get (rest_endpoint )
40- assert (context .resp .status_code == HTTP_200_OK )
43+ context .resp = requests .get (rest_endpoint , timeout = WAIT_TIMEOUT )
44+ expect (context .resp .status_code ).equal_to (HTTP_200_OK )
45+ # and delete them one by one
4146 for pet in context .resp .json ():
42- context .resp = requests .delete (f"{ rest_endpoint } /{ pet ['id' ]} " )
43- assert (context .resp .status_code == HTTP_204_NO_CONTENT )
47+ context .resp = requests .delete (f"{ rest_endpoint } /{ pet ['id' ]} " , timeout = WAIT_TIMEOUT )
48+ expect (context .resp .status_code ). equal_to ( HTTP_204_NO_CONTENT )
4449
4550 # load the database with new pets
4651 for row in context .table :
@@ -51,5 +56,5 @@ def step_impl(context):
5156 "gender" : row ['gender' ],
5257 "birthday" : row ['birthday' ]
5358 }
54- context .resp = requests .post (rest_endpoint , json = payload )
55- assert (context .resp .status_code == HTTP_201_CREATED )
59+ context .resp = requests .post (rest_endpoint , json = payload , timeout = WAIT_TIMEOUT )
60+ expect (context .resp .status_code ). equal_to ( HTTP_201_CREATED )
0 commit comments