Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def gen_create_post(post_id):
    data = {
        'title': TITLES,
        'body': BODY_RESOURCE,
        'userId': post_id
    }
    response = Client().create_post(data)
    check_create_resource(response)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def test_get_posts_by_nonexistent_id(self, id):
     response = Client().get_posts_by_id(id)
     status_code_check(response, codes.not_found)
Ejemplo n.º 6
0
 def test_get_posts_by_id(self, id):
     response = Client().get_posts_by_id(id)
     check_get_post_contains_id_response(response, id)
Ejemplo n.º 7
0
 def test_get_posts_by_invalid_id(self, id):
     response = Client().get_posts_by_id(id)
     status_code_check(response, codes.bad_request)
Ejemplo n.º 8
0
def client():
    return Client()
Ejemplo n.º 9
0
 def test_get_all_posts(self):
     response = Client().get_all_posts()
     check_get_all_posts_response(response)
Ejemplo n.º 10
0
 def test_post_posts_non_body(self):
     response = Client().post_posts()
     status_code_check(response, codes.created)
Ejemplo n.º 11
0
 def test_delete_by_id(self, id):
     response = Client().delete_posts_by_id(id)
     status_code_check(response, codes.ok)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
def test_create_resource_b(data):
    response = Client().create_resource_bad(data)
    check_create_resource(response)
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 def test_post_posts_by_invalid_str_body(self, body):
     response = Client().post_posts_by_body(body)
     status_code_check(response, codes.bad_request)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 21
0
def test_get_specific_resource_negative():
    response = Client().get_post_by_id(USER_IDS[0])
    check_get_id(response)
Ejemplo n.º 22
0
 def test_post_posts_by_json_body(self, body_json):
     response = Client().post_posts_by_body(body_json)
     status_code_check(response, codes.created)
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
 def test_create_invalid_post(self, data):
     response = Client().create_new_post(data)
     check.check_response_code(response, 404)
Ejemplo n.º 25
0
 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)
Ejemplo n.º 26
0
def client():
    client = Client()
    return client
 def test_create_invalid_post(self):
     response = Client().create_invalid_post()
     check_post_is_not_created(response)
Ejemplo n.º 28
0
def test_delete_resource(create_post):
    response = Client().delete_post(create_post)
    response_general_check(response)
Ejemplo n.º 29
0
def test_delete_resource():
    data = {
        'title': 'New title for post'
    }
    response = Client().patch_post(USER_IDS[0], data)
    response_general_check(response)
Ejemplo n.º 30
0
 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)