def test_delete_all(self, test_api, create_bear, bear_name, bear_type, bears_count): """test delete all bears.""" for _ in range(bears_count): with allure.step("Create new bear"): create_bear(bear_name=bear_name, bear_type=bear_type, bear_age=Utils.get_random_int()) with allure.step("Get all bears before delete"): all_bears_before = test_api.get_bears() with allure.step("Delete bears"): delete_bears = test_api.delete_all_bears() assert_that(delete_bears, equal_to(ResultMsgs.OK), 'Delete was not successful') with allure.step("Get all bears after delete"): all_bears_after = test_api.get_bears() with allure.step("Check that new bear is present in DB"): assert_that( len(all_bears_before) - bears_count, equal_to(len(all_bears_after)), 'Number of bears not equal to expected')
def test_get_exist_bear(self, test_api, create_bear): """test get existed bear by id.""" with allure.step("Create new bear"): new_bear = create_bear(bear_name=Utils.get_random_string(), bear_type=Utils.get_random_bear_type(), bear_age=Utils.get_random_int()) with allure.step("Get exist bear by id"): exist_bear = test_api.get_bear(bear_id=new_bear.bear_id) with allure.step("Check that exist bear equal to expected"): assert_that( exist_bear, has_properties(bear_id=new_bear.bear_id, bear_type=new_bear.bear_type, bear_name=new_bear.name, bear_age=new_bear.age), 'Exist bear not equal to expected')
def test_get_all_bears(self, test_api, create_bear): """Test for checking GET all bears.""" with allure.step("Get all bears before create new"): all_bears_before = test_api.get_bears() with allure.step("Create new random bear"): new_bear = create_bear(bear_name=Utils.get_random_string(), bear_type=Utils.get_random_bear_type(), bear_age=Utils.get_random_int()) with allure.step("Check that new bear is unique"): assert_that( all_bears_before, is_not( has_items( has_properties(bear_id=new_bear.bear_id, bear_type=new_bear.bear_type, bear_name=new_bear.name, bear_age=new_bear.age))), 'DB already has info about created bear') with allure.step("Get all bears after create new"): all_bears_after = test_api.get_bears() with allure.step("Check that new bear is present in DB"): assert_that(len(all_bears_before), less_than(len(all_bears_after)), 'Number of bears not equal to expected') assert_that( all_bears_after, has_items( has_properties(bear_id=new_bear.bear_id, bear_type=new_bear.bear_type, bear_name=new_bear.name, bear_age=new_bear.age)), 'No info about created bear in DB')