2018-09-18 09:21:57 +03:00
|
|
|
import yaml
|
|
|
|
from validate import check_query_f
|
2018-10-28 21:27:49 +03:00
|
|
|
from super_classes import DefaultTestSelectQueries
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
class TestGraphQLQueryBasic(DefaultTestSelectQueries):
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_select_query_author(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_author.yaml')
|
|
|
|
|
|
|
|
def test_select_various_postgres_types(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_test_types.yaml')
|
|
|
|
|
|
|
|
def test_select_query_author_quoted_col(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_author_col_quoted.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_select_query_author_pk(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_author_by_pkey.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_select_query_where(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_author_where.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_nested_select_query_article_author(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_query_article_author.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-12 12:28:43 +03:00
|
|
|
def test_nested_select_query_deep(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_query_deep.yaml')
|
2018-10-12 12:28:43 +03:00
|
|
|
|
2018-09-18 09:21:57 +03:00
|
|
|
def test_nested_select_query_where(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_where_query_author_article.yaml')
|
|
|
|
|
|
|
|
def test_nested_select_query_where_on_relationship(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_query_article_author_where_on_relationship.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-05 08:16:21 +03:00
|
|
|
def test_select_query_user(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/select_query_user.yaml")
|
|
|
|
|
|
|
|
def test_select_query_non_tracked_table(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/select_query_non_tracked_table_err.yaml")
|
2018-10-05 08:16:21 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
def test_select_query_col_not_present_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/select_query_author_col_not_present_err.yaml")
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/basic'
|
|
|
|
|
|
|
|
|
|
|
|
class TestGraphQLQueryAgg(DefaultTestSelectQueries):
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_article_agg_count_sum_avg_max_min_with_aliases(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/article_agg_count_sum_avg_max_min_with_aliases.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_article_agg_where(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/article_agg_where.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_author_agg_with_articles(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/author_agg_with_articles.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_author_agg_with_articles_where(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/author_agg_with_articles_where.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
2018-11-12 10:28:46 +03:00
|
|
|
def test_article_deeply_nested_aggregate(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/article_deeply_nested_aggregate.yaml')
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/aggregations'
|
2018-10-26 12:02:44 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
class TestGraphQLQueryAggPerm(DefaultTestSelectQueries):
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_author_agg_articles(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/author_agg_articles.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_article_agg_fail(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/article_agg_fail.yaml')
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
def test_author_articles_agg_fail(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/author_articles_agg_fail.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/agg_perm'
|
2018-10-26 12:02:44 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestGraphQLQueryLimits(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_limit_1(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_limit_1.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_limit_2(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_limit_2.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_str_limit_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_string_limit_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_neg_limit_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_neg_limit_error.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/limits'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
class TestGraphQLQueryOffsets(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_offset_1_limit_2(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_offset_1_limit_2.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_offset_2_limit_1(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_offset_2_limit_1.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_int_as_string_offset(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_string_offset.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_neg_offset_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_neg_offset_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/offset'
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestGraphQLQueryBoolExpBasic(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_not_equal(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_neq.yaml')
|
|
|
|
|
|
|
|
def test_author_article_operator_ne_not_found_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_operator_ne_not_found_err.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_greater_than(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_gt.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_greater_than_or_equal(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_gte.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_less_than(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_lt.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_less_than_or_equal(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_lte.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_in(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_in.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_nin(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_nin.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_order_delivered_at_is_null(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_null.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_order_delivered_at_is_not_null(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_not_null.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_article_where_not_less_than(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_not_lt.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_article_author_is_published_and_registered(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_is_published_and_registered.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_article_author_not_published_nor_registered(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_not_published_or_not_registered.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
def test_article_author_unexpected_operator_in_where_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_unexpected_operator_in_where_err.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/boolexp/basic'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
class TestGraphqlQueryPermissions(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_select_unpublished_articles(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_select_query_unpublished_articles.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_only_other_users_published_articles(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_other_users_published_articles.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_anonymous_only_published_articles(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/anonymous_can_only_get_published_articles.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_cannot_access_remarks_col(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_cannot_access_remarks_col.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-11-02 12:36:33 +03:00
|
|
|
def test_artist_select_query_Track_fail(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/artist_select_query_Track_fail.yaml')
|
|
|
|
|
|
|
|
def test_artist_select_query_Track(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/artist_select_query_Track.yaml')
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/permissions'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestGraphQLQueryBoolExpSearch(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_like(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_like.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_not_like(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_nlike.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_ilike(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_ilike.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_not_ilike(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_nilike.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_similar(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_similar.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_city_where_not_similar(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_city_where_not_similar.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/boolexp/search'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestGraphQLQueryBoolExpJsonB(DefaultTestSelectQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_contains_article_latest(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contains_latest.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_contains_article_beststeller(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_jsonb_contains_bestseller.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_contained_in_latest(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contained_in_latest.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_contained_in_bestseller_latest(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contained_in_bestseller_latest.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_has_key_sim_type(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_key_sim_type.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_has_keys_any_os_operating_system(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_keys_any_os_operating_system.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_jsonb_has_keys_all_touchscreen_ram(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_keys_all_ram_touchscreen.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/boolexp/jsonb'
|
|
|
|
|
|
|
|
|
|
|
|
class TestGraphQLQueryOrderBy(DefaultTestSelectQueries):
|
2018-10-26 14:57:33 +03:00
|
|
|
def test_articles_order_by_without_id(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/articles_order_by_without_id.yaml')
|
2018-10-26 14:57:33 +03:00
|
|
|
|
|
|
|
def test_articles_order_by_rel_author_id(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/articles_order_by_rel_author_id.yaml')
|
2018-10-26 14:57:33 +03:00
|
|
|
|
|
|
|
def test_articles_order_by_rel_author_rel_contact_phone(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/articles_order_by_rel_author_rel_contact_phone.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/graphql_query/order_by'
|