def test_2_title_empty(self): body = {api.param_title: ""} tc_recipe = recipe_model.RecipeTest().custom(body) """ cal api """ url = server.main_url + "/" + api.url response = requests.post(url, json=body, verify=False) response_body = response.json() """ assert """ self.assertEqual(response.status_code, 400) self.assertEqual(response.headers["Content-Type"], 'application/json', ) self.assertEqual(response_body[api.rep_code_status], 400) self.assertEqual(response_body[api.rep_code_msg], api.rep_code_msg_error_400) detail = api.create_detail(api.param_title, server.detail_must_be_not_empty, body[api.param_title]) self.assertEqual(response_body[api.rep_detail], detail) tc_recipe.select_nok_by_title()
def test_11_title_already_exist(self): tc_recipe = recipe_model.RecipeTest().custom_test({}).insert() body = {api.param_title: tc_recipe.get_data_value("title")} """ cal api """ url = server.main_url + "/" + api.url response = requests.post(url, json=body, verify=False) response_body = response.json() """ assert """ self.assertEqual(response.status_code, 400) self.assertEqual(response.headers["Content-Type"], 'application/json') self.assertEqual(response_body[api.rep_code_status], 400) self.assertEqual(response_body[api.rep_code_msg], api.rep_code_msg_error_400) detail = api.create_detail(api.param_title, server.detail_already_exist, body[api.param_title]) self.assertEqual(response_body[api.rep_detail], detail) tc_recipe.select_ok()
def test_9_ingredients_string(self): body = {api.param_title: "qa_rhr_title", api.param_ingredients: "invalid"} tc_recipe = recipe_model.RecipeTest().custom(body) """ cal api """ url = server.main_url + "/" + api.url response = requests.post(url, json=body, verify=False) response_body = response.json() """ assert """ self.assertEqual(response.status_code, 400) self.assertEqual(response.headers["Content-Type"], 'application/json') self.assertEqual(response_body[api.rep_code_status], 400) self.assertEqual(response_body[api.rep_code_msg], api.rep_code_msg_error_400) detail = api.create_detail(api.param_ingredients, server.detail_must_be_an_object, body[api.param_ingredients]) self.assertEqual(response_body[api.rep_detail], detail) tc_recipe.select_nok_by_title()