def test_get_pet_200(self):
     response = get_v2_pet(self.client, self.pet['id'])
     assert_status_code(response, 200)
     assert_max_response_time(response, 1)
     assert_valid_schema(response.json(), 'pet/v2_pet.json')
     assert_response_key_value(response, 'id', self.pet['id'])
     assert_response_key_value(response, 'name', self.pet['name'])
    def test_pet(self):
        client = Client()
        pet = generate_pet()

        # POST a pet
        response = post_v2_pet(client, **pet)
        assert_status_code(response, 200)
        assert_max_response_time(response, 1)
        assert_valid_schema(response.json(), 'pet/v2_pet.json')

        # GET a pet
        response = get_v2_pet(client, pet['id'])
        assert_status_code(response, 200)
        assert_max_response_time(response, 1)
        assert_valid_schema(response.json(), 'pet/v2_pet.json')
        assert_response_key_value(response, 'id', pet['id'])
        assert_response_key_value(response, 'name', pet['name'])

        # PUT a pet
        pet['name'] = 'NewName'
        response = put_v2_pet(client, **pet)
        assert_status_code(response, 200)
        assert_max_response_time(response, 1)
        assert_valid_schema(response.json(), 'pet/v2_pet.json')
        assert_response_key_value(response, 'id', pet['id'])
        assert_response_key_value(response, 'name', pet['name'])

        # DELETE
        response = delete_v2_pet(client, pet['id'])
        assert_status_code(response, 200)
        assert_max_response_time(response, 1)

        # GET a pet
        response = get_v2_pet(client, pet['id'])
        assert_status_code(response, 404)
    def test_get_pet(self):

        pet_id, pet_name = 21435431254521, 'Garfield'
        payload = {
            "id": pet_id,
            "name": "Garfield",
            "category": {
                "name": "cats"
            },
            "status": "available"
        }

        # POST a pet
        requests.post(url='https://petstore.swagger.io/v2/pet', json=payload)

        # GET a pet
        response = requests.get(url=f'https://petstore.swagger.io/v2/pet/{pet_id}')

        assert_status_code(response, 200)
        assert_max_response_time(response, 1)
        assert_valid_schema(response.json(), 'pet/v2_pet.json')
        assert_response_key_value(response, 'id', pet_id)
        assert_response_key_value(response, 'name', pet_name)
 def test_get_deleted_pet_404(self):
     delete_v2_pet(self.client, self.pet['id'])
     response = get_v2_pet(self.client, self.pet['id'])
     assert_status_code(response, 404)
     assert_max_response_time(response, 1)
 def test_delete_pet_200(self):
     self.created_pet_post_response = ''
     response = delete_v2_pet(self.client, self.pet['id'])
     assert_status_code(response, 200)
     assert_max_response_time(response, 1)