graphql-engine/server/tests-py/test_apis_disabled.py
Anon Ray a21f6cd648 introduce v1/graphql (fix #1368) (#2064)
Changes compared to `/v1alpha1/graphql`

* Changed all graphql responses in **/v1/graphql** endpoint to be 200. All graphql clients expect responses to be HTTP 200. Non-200 responses are considered transport layer errors. 

* Errors in http and websocket layer are now consistent and have similar structure.
2019-05-10 11:35:10 +05:30

58 lines
1.9 KiB
Python

#!/usrbin/env python3
import pytest
from validate import check_query, check_query_f
def check_post_404(hge_ctx,url):
return check_query(hge_ctx, {
'url': url,
'status': 404,
'query': {}
})
@pytest.mark.skipif(not pytest.config.getoption("--test-metadata-disabled"),
reason="flag --test-metadata-disabled is not set. Cannot run tests for metadata disabled")
class TestMetadataDisabled:
def test_metadata_v1_query_disabled(self, hge_ctx):
check_post_404(hge_ctx,'/v1/query')
def test_metadata_v1_template_disabled(self, hge_ctx):
check_post_404(hge_ctx,'/v1/template/foo')
def test_metadata_api_1_disabled(self, hge_ctx):
check_post_404(hge_ctx,'/api/1/table/foo/select')
@pytest.mark.skipif(not pytest.config.getoption("--test-graphql-disabled"),
reason="--test-graphql-disabled is not set. Cannot run GraphQL disabled tests")
class TestGraphQLDisabled:
def test_graphql_endpoint_disabled(self, hge_ctx):
check_post_404(hge_ctx, '/v1/graphql')
def test_graphql_explain_disabled(self, hge_ctx):
check_post_404(hge_ctx, '/v1/graphql/explain')
@pytest.mark.skipif(pytest.config.getoption("--test-graphql-disabled"),
reason="--test-graphql-disabled is set. Cannot run GraphQL enabled tests")
class TestGraphQLEnabled:
def test_graphql_introspection(self, hge_ctx):
check_query_f(hge_ctx, "queries/graphql_introspection/introspection_only_kind_of_queryType.yaml")
@pytest.mark.skipif(pytest.config.getoption("--test-metadata-disabled"),
reason="--test-metadata-disabled is set. Cannot run metadata enabled tests")
class TestMetadataEnabled:
def test_reload_metadata(self, hge_ctx):
check_query_f(hge_ctx, "queries/v1/metadata/reload_metadata.yaml")
def test_run_sql(self, hge_ctx):
check_query_f(hge_ctx, "queries/v1/run_sql/sql_set_timezone.yaml")