client = <FlaskClient <Flask 'swh.graphql.tests.conftest'>>
def test_query_cost_origin(client):
query_str = """
{
origins(first: 10) {
nodes {
url
latestVisit {
date
}
visits(first: 5) {
nodes {
date
statuses {
nodes {
date
}
}
}
}
snapshots(first: 5) {
nodes {
swhid
}
}
}
}
}
"""
# Total cost here is 170
# 10 (origin) + 10 (latestVisit) + 10*5 (visits) + 10 * 5 * 3 (status) +
# 10 * 5*2 (snapshots) = 320
> errors = utils.get_error_response(client, query_str)
.tox/py3/lib/python3.7/site-packages/swh/graphql/tests/functional/test_query_cost.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/graphql/tests/functional/utils.py:29: in get_error_response
data, errors = get_query_response(client, query_str, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <FlaskClient <Flask 'swh.graphql.tests.conftest'>>
query_str = '\n {\n origins(first: 10) {\n nodes {\n url\n latestVisit {\n date\n ...ots(first: 5) {\n nodes {\n swhid\n }\n }\n }\n }\n }\n '
kwargs = {}
query = '\n {\n origins(first: 10) {\n nodes {\n url\n latestVisit {\n date\n ...ots(first: 5) {\n nodes {\n swhid\n }\n }\n }\n }\n }\n '
response = <WrapperTestResponse 161 bytes [400 BAD REQUEST]>, @py_assert1 = 400
@py_assert4 = 200, @py_assert3 = False
@py_format6 = '400\n{400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code\n} == 200'
@py_format8 = 'b\'{"errors":[{"extensions":{"cost":{"maximumAvailable":100,"requestedQueryCost":320}},"message":"The query exceeds t...ctual cost is 320"}]}\n~\'\n>assert 400\n{400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code\n} == 200'
def get_query_response(client, query_str: str, **kwargs) -> Tuple[Dict, Dict]:
query = gql(query_str)
response = client.post("/", json={"query": query, "variables": kwargs})
> assert response.status_code == 200, response.data
E AssertionError: b'{"errors":[{"extensions":{"cost":{"maximumAvailable":100,"requestedQueryCost":320}},"message":"The query exceeds the maximum cost of 100. Actual cost is 320"}]}
E '
E assert 400 == 200
E + where 400 = <WrapperTestResponse streamed [400 BAD REQUEST]>.status_code
.tox/py3/lib/python3.7/site-packages/swh/graphql/tests/functional/utils.py:15: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 17 2022, 12:32 PM