2021-01-29 04:02:34 +03:00
|
|
|
import pytest
|
|
|
|
import os
|
|
|
|
from validate import check_query_f, check_query, get_conf_f
|
|
|
|
from context import PytestConf
|
|
|
|
|
2021-02-13 03:05:23 +03:00
|
|
|
import redis
|
|
|
|
|
2021-01-29 04:02:34 +03:00
|
|
|
@pytest.mark.parametrize("transport", ['http'])
|
2022-08-15 17:29:02 +03:00
|
|
|
@pytest.mark.usefixtures('postgis', 'per_class_tests_db_state')
|
2021-01-29 04:02:34 +03:00
|
|
|
class TestCustomEndpoints:
|
2021-02-13 03:05:23 +03:00
|
|
|
def flushRedis(self):
|
|
|
|
# TODO: Move this into setup/teardown
|
|
|
|
r = redis.from_url(PytestConf.config.getoption('--redis-url'))
|
|
|
|
r.flushall()
|
2021-01-29 04:02:34 +03:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/endpoints'
|
|
|
|
|
|
|
|
def test_missing_endpoint(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_missing.yaml', transport)
|
|
|
|
|
2021-07-16 19:08:23 +03:00
|
|
|
def test_endpoint_as_user_err(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_as_user_err.yaml', transport)
|
|
|
|
|
2021-01-29 04:02:34 +03:00
|
|
|
def test_simple_endpoint(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_simple.yaml', transport)
|
|
|
|
|
|
|
|
def test_simple_endpoint_wrong_method(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_simple_wrong_method.yaml', transport)
|
|
|
|
|
2021-02-13 03:05:23 +03:00
|
|
|
@pytest.mark.skipif(not PytestConf.config.getoption('--redis-url'), reason="Must enable redis")
|
2021-01-29 04:02:34 +03:00
|
|
|
def test_simple_cached_endpoint(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_simple_cached.yaml', transport)
|
2021-02-13 03:05:23 +03:00
|
|
|
self.flushRedis()
|
2021-01-29 04:02:34 +03:00
|
|
|
|
|
|
|
def test_endpoint_with_query_arg(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_query_arg.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_with_body_arg(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_body_arg.yaml', transport)
|
|
|
|
|
2021-12-04 00:56:25 +03:00
|
|
|
def test_endpoint_with_body_list_arg(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_list_arg.yaml', transport)
|
|
|
|
|
2021-01-29 04:02:34 +03:00
|
|
|
def test_endpoint_with_query_arg_url_encoded(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_query_arg_url_encoded.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_with_query_arg_url_encoded_2(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_query_arg_url_encoded_2.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_with_query_args_missing_arg(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_query_arg_missing_arg.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_with_multiple_query_args(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_multiple_query_args.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_with_template(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_template.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_dropped(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_dropped.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_conflicting(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_conflicting.yaml', transport)
|
|
|
|
|
2021-02-24 07:30:12 +03:00
|
|
|
def test_endpoint_duplicate_param(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_duplicate_param.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_empty_path(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_empty_path.yaml', transport)
|
2021-03-10 08:25:12 +03:00
|
|
|
|
2021-02-24 07:30:12 +03:00
|
|
|
def test_endpoint_trailing_slash(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_trailing_slash.yaml', transport)
|
2021-03-10 08:25:12 +03:00
|
|
|
|
2021-02-24 07:30:12 +03:00
|
|
|
def test_endpoint_empty_path_segment(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_empty_path_segment.yaml', transport)
|
|
|
|
|
|
|
|
def test_endpoint_empty_path_param(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_empty_path_param.yaml', transport)
|
|
|
|
|
2021-05-06 09:43:09 +03:00
|
|
|
def test_endpoint_uuid_arg(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_with_uuid_arg.yaml', transport)
|
|
|
|
|
2021-02-24 07:30:12 +03:00
|
|
|
def test_endpoint_subscription(self, hge_ctx, transport):
|
2021-03-10 08:25:12 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_subscription.yaml', transport)
|
2022-02-08 07:46:57 +03:00
|
|
|
|
|
|
|
def test_query_validation(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_query_validation.yaml', transport)
|
2022-05-02 06:33:17 +03:00
|
|
|
|
|
|
|
def test_endpoint_with_pg_date_url_variable(self, hge_ctx, transport):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/endpoint_pg_date_url_variable.yaml', transport)
|