Exemplo n.º 1
0
def test_like_post_and_check_liked(get_post_id):
    liked = 1
    post_id = get_post_id
    helpers.send_request('/likes.add', item_id=post_id)
    result = helpers.send_request('/likes.isLiked', item_id=post_id)
    with allure.step("Post is in Liked for user"):
        assert helpers.check_response(result)['liked'] == liked, \
            f"Post is not in liked. Result: {result}"
Exemplo n.º 2
0
def test_like_post_and_check_list(get_post_id):
    liked = 1
    post_id = get_post_id
    helpers.send_request('/likes.add', item_id=post_id)
    result = helpers.send_request('/likes.getList', item_id=post_id)
    with allure.step("One user liked post"):
        assert helpers.check_response(result)['count'] == liked, \
            f"Post is not liked. Result: {result}"
Exemplo n.º 3
0
def test_liked_for_user_with_wrong_id(get_post_id):
    wrong_id = 12112342
    post_id = get_post_id
    result = helpers.send_request('/likes.isLiked',
                                  item_id=post_id,
                                  user_id=wrong_id,
                                  owner_id=wrong_id)
    with allure.step("Access denied error"):
        assert 'Access denied' in helpers.check_error(result)['error_msg'], \
            f"Error message is incorrect. Result: {result}"
Exemplo n.º 4
0
def get_post_id():
    with allure.step("Creating new Post for test data"):
        params_wall_post = {
            'message': test_data.food.fruit(),
            'owner_id': auth.USER_ID
        }
        post_id = None
        response = helpers.send_request('/wall.post', **params_wall_post)
        if response is not None:
            post_id = response['response']['post_id']

        yield post_id

    with allure.step("Cleaning up test data"):
        params_wall_delete = {
            'post_id': post_id,
            'owner_id': auth.USER_ID
        }
        helpers.send_request('/wall.delete', **params_wall_delete)
Exemplo n.º 5
0
def test_get_list_with_incorrect_post_id(get_post_id):
    post_id = get_post_id * 1000
    result = helpers.send_request('/likes.delete', item_id=post_id)
    with allure.step("Post not found"):
        assert 'object was not found' in helpers.check_error(result)['error_msg'], \
            f"Error message is incorrect. Result: {result}"