Advertisement
M1KK0

Python test sample

Oct 7th, 2022
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. @pytest.mark.parametrize("state, expected", [
  2.     ('available', 580),
  3.     ('pending', 5),
  4.     ('sold', 10),
  5. ])
  6. def test_2_middle(state, expected):
  7.     # CONDITION = "status=pending"
  8.     CONDITION = {"status": f'{state}'}
  9.     HEADERS = {'accept': 'application/json'}
  10.  
  11.     # swagger_url = f'{URL}{ENDPOINT}?{CONDITION}'
  12.     swagger_url = f'{URL}{ENDPOINT}'
  13.  
  14.     response = requests.get(url=swagger_url,
  15.                             headers=HEADERS,
  16.                             params=CONDITION)
  17.     response.raise_for_status()
  18.  
  19.     pet_list = response.json()
  20.     pet_count = len(pet_list)
  21.  
  22.     assert_that(
  23.         actual=pet_count,
  24.         matcher=greater_than(expected),
  25.         reason=f'{pet_count} not more than {expected}'
  26.     )
Tags: Test sample
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement