def test_orderby_fails(client: FlaskClient, orderby: str, err_segment: str):
    response = client.get('/user', query_string={
        'orderby': orderby,
    })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.BAD_REQUEST
    assert err_segment in response['message']
def test_orderby_succeeds(client: FlaskClient, orderby: str, ids: List[int]):
    response = client.get('/user', query_string={
        'orderby': orderby,
    })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.OK
    assert [user['id'] for user in response] == ids
def test_user_filters_succeeds(client: FlaskClient, filters, ids):
    response = client.get('/user', query_string={
        'filter': filters,
    })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.OK
    assert [user['id'] for user in response] == ids
def test_joined_with_invalid_property_fails(client: FlaskClient, filters: str,
                                            err_segment: str):
    response = client.get('/comment', query_string={
        'filter': filters,
    })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.BAD_REQUEST
    assert err_segment in response['message']
def test_joined_filter_succeeds(client: FlaskClient, filters: str,
                                ids: List[int]):
    response = client.get('/comment', query_string={
        'filter': filters,
    })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.OK
    assert ids == [comment['id'] for comment in response]
def test_with_paging_succeeds(client: FlaskClient, filters: str, orderby: str,
                              page_size: int, page: int, ids: List[int]):
    response = client.get('/comment',
                          query_string={
                              'filter': filters,
                              'orderby': orderby,
                              'page_size': page_size,
                              'page': page,
                          })
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.OK
    assert [comment['id'] for comment in response] == ids
def test_default_orderby_succeeds(client: FlaskClient):
    response = client.get('/role', )
    status_code, response = response.status_code, parse_response(response)
    assert status_code == HTTPStatus.OK
    assert [role['id'] for role in response] == [2, 1]