2019-02-28 16:53:03 +03:00
|
|
|
#!/usrbin/env python3
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from validate import check_query, check_query_f
|
2019-11-29 08:14:26 +03:00
|
|
|
from context import PytestConf
|
2019-02-28 16:53:03 +03:00
|
|
|
|
|
|
|
def check_post_404(hge_ctx,url):
|
|
|
|
return check_query(hge_ctx, {
|
|
|
|
'url': url,
|
|
|
|
'status': 404,
|
|
|
|
'query': {}
|
2019-09-04 18:02:35 +03:00
|
|
|
})[0]
|
2019-02-28 16:53:03 +03:00
|
|
|
|
2019-11-29 08:14:26 +03:00
|
|
|
metadata_api_disabled = PytestConf.config.getoption("--test-metadata-disabled")
|
|
|
|
graphql_api_disabled = PytestConf.config.getoption("--test-graphql-disabled")
|
2019-02-28 16:53:03 +03:00
|
|
|
|
2019-11-29 08:14:26 +03:00
|
|
|
@pytest.mark.skipif(not metadata_api_disabled,
|
2019-02-28 16:53:03 +03:00
|
|
|
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')
|
|
|
|
|
2020-01-22 13:50:49 +03:00
|
|
|
def test_graphql_explain_disabled(self, hge_ctx):
|
|
|
|
check_post_404(hge_ctx, '/v1/graphql/explain')
|
2019-02-28 16:53:03 +03:00
|
|
|
|
2019-11-29 08:14:26 +03:00
|
|
|
@pytest.mark.skipif(not graphql_api_disabled,
|
2019-02-28 16:53:03 +03:00
|
|
|
reason="--test-graphql-disabled is not set. Cannot run GraphQL disabled tests")
|
|
|
|
class TestGraphQLDisabled:
|
|
|
|
|
|
|
|
def test_graphql_endpoint_disabled(self, hge_ctx):
|
2019-05-10 09:05:11 +03:00
|
|
|
check_post_404(hge_ctx, '/v1/graphql')
|
2019-02-28 16:53:03 +03:00
|
|
|
|
2019-11-29 08:14:26 +03:00
|
|
|
@pytest.mark.skipif(graphql_api_disabled,
|
2019-02-28 16:53:03 +03:00
|
|
|
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")
|
|
|
|
|
|
|
|
|
2019-11-29 08:14:26 +03:00
|
|
|
@pytest.mark.skipif(metadata_api_disabled,
|
2019-02-28 16:53:03 +03:00
|
|
|
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")
|
|
|
|
|
|
|
|
|