def test_create_resource(prepared_resource_id): data = { "title": TITLES[0], "body": BODY_RESOURCE, "userId": prepared_resource_id } response = Client().create_post(data) check_create_resource(response)
def gen_create_post(post_id): data = { 'title': TITLES, 'body': BODY_RESOURCE, 'userId': post_id } response = Client().create_post(data) check_create_resource(response)
def test_update_resource(): data = { 'id': 1, 'title': 'New title for post', 'body': 'New body for post', 'userId': USER_IDS[0], } response = Client().update_post(USER_IDS[0], data) response_general_check(response)
def test_get_posts_by_params_combo(self, params): expected_post = { 'userId': 1, 'id': 1, 'title': 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', 'body': 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum' '\nreprehenderit molestiae ut ut quas totam' '\nnostrum rerum est autem sunt rem eveniet architecto' } response = Client().get_posts_by_params(params) check_post_post_contains_id_response(response, expected_post)
def test_get_posts_by_nonexistent_id(self, id): response = Client().get_posts_by_id(id) status_code_check(response, codes.not_found)
def test_get_posts_by_id(self, id): response = Client().get_posts_by_id(id) check_get_post_contains_id_response(response, id)
def test_get_posts_by_invalid_id(self, id): response = Client().get_posts_by_id(id) status_code_check(response, codes.bad_request)
def client(): return Client()
def test_get_all_posts(self): response = Client().get_all_posts() check_get_all_posts_response(response)
def test_post_posts_non_body(self): response = Client().post_posts() status_code_check(response, codes.created)
def test_delete_by_id(self, id): response = Client().delete_posts_by_id(id) status_code_check(response, codes.ok)
def test_put_posts_by_id(self, id, body_json): response = Client().put_posts_by_id(id, body_json) status_code_check(response, codes.ok)
def test_put_posts_by_invalid_id(self, id, body_json): response = Client().put_posts_by_id(id, body_json) status_code_check(response, codes.bad_request)
def test_create_resource_b(data): response = Client().create_resource_bad(data) check_create_resource(response)
def test_create_valid_post(self, valid_data): response = Client().create_new_comment(valid_data) check.check_response_code(response, 201) check.check_response_data(response, valid_data)
def test_post_posts_and_get(self, body_json): client = Client() response = client.post_posts_by_body(body_json) response_new_post = client.get_posts_by_id(response.json()['id']) check_posts_the_same(response_new_post, body_json)
def test_post_posts_by_invalid_str_body(self, body): response = Client().post_posts_by_body(body) status_code_check(response, codes.bad_request)
def test_post_posts_by_invalid_json_body(self, post_invalid_json): response = Client().post_posts_by_body(post_invalid_json) status_code_check(response, codes.bad_request)
def test_get_posts_by_params(self): response = Client().get_posts_by_params(POST_FOR_TEST) id = POST_FOR_TEST['id'] check_get_post_contains_id_response_by_params(response, id)
def test_create_post(self): response = Client().create_post() check_post_is_created(response)
def test_get_specific_resource_negative(): response = Client().get_post_by_id(USER_IDS[0]) check_get_id(response)
def test_post_posts_by_json_body(self, body_json): response = Client().post_posts_by_body(body_json) status_code_check(response, codes.created)
def test_put_posts_by_id_body(self, id, body_json): response = Client().put_posts_by_id(id, body_json) check_put_post_contains_id_response(response, id)
def test_create_invalid_post(self, data): response = Client().create_new_post(data) check.check_response_code(response, 404)
def test_put_posts_by_nonexistent_id(self, id, body_json): response = Client().put_posts_by_id(id, body_json) status_code_check(response, codes.not_found)
def client(): client = Client() return client
def test_create_invalid_post(self): response = Client().create_invalid_post() check_post_is_not_created(response)
def test_delete_resource(create_post): response = Client().delete_post(create_post) response_general_check(response)
def test_delete_resource(): data = { 'title': 'New title for post' } response = Client().patch_post(USER_IDS[0], data) response_general_check(response)
def test_positive_add_new_post(self): data_json = generate_post() response = Client().post_new_posts(data_json) check_add_new_post(data_json, response)