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, DefaultTestQueries
|
|
|
|
|
2018-12-21 12:54:22 +03:00
|
|
|
class TestDropNoColsTable:
|
|
|
|
def test_drop_no_cols_table(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, 'queries/v1/ddl/drop_no_cols_table.yaml')
|
2018-10-30 12:21:58 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1General(DefaultTestQueries):
|
|
|
|
|
|
|
|
def test_query_string_input_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_string_input_err.yaml')
|
|
|
|
|
|
|
|
def test_query_unknown_type_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_unknown_type_err.yaml')
|
|
|
|
|
|
|
|
def test_query_args_as_string_err(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_args_as_string_err.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/basic"
|
|
|
|
|
2018-10-30 12:21:58 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1SelectBasic(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_article.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_nested_select_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')
|
|
|
|
|
|
|
|
def test_nested_select_article_author_alias_for_relationship(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_query_article_author_rel_alias.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_select_author_where(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_author_where.yaml')
|
|
|
|
|
|
|
|
def test_select_table_not_present(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_table_not_present_err.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-09-18 09:21:57 +03:00
|
|
|
def test_select_col_not_present(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_col_not_present_err.yaml')
|
|
|
|
|
|
|
|
def test_select_nested_where_query(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/nested_select_where_query_author_article.yaml')
|
2018-10-04 15:44:15 +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_user.yaml')
|
2018-10-05 08:16:21 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/select/basic"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1SelectLimits(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/v1/select/limits'
|
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 TestV1SelectOffset(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_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_query_article_int_as_string_offset_error.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/v1/select/offset'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1SelectBoolExpBasic(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')
|
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
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/v1/select/boolexp/basic'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1SelectBoolExpSearch(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')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/v1/select/boolexp/search'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2019-01-28 20:46:31 +03:00
|
|
|
class TestV1SelectBoolExpJSONB(DefaultTestSelectQueries):
|
|
|
|
|
|
|
|
def test_select_article_author_jsonb_contained_in_bestseller_latest(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contained_in_bestseller_latest.yaml')
|
|
|
|
|
|
|
|
def test_select_article_author_jsonb_contained_in_latest(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contained_in_latest.yaml')
|
|
|
|
|
|
|
|
def test_select_article_author_jsonb_contains_latest(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_article_author_jsonb_contains_latest.yaml')
|
|
|
|
|
|
|
|
def test_select_author_article_jsonb_contains_bestseller(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_author_article_jsonb_contains_bestseller.yaml')
|
|
|
|
|
|
|
|
# TODO:- Uncomment the following after adding has_keys_all and has_keys_any operators
|
|
|
|
# def test_select_product_jsonb_has_keys_all_ram_touchscreen(self, hge_ctx):
|
|
|
|
# check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_keys_all_ram_touchscreen.yaml')
|
|
|
|
|
|
|
|
# def test_select_product_jsonb_has_keys_any_os_operating_system(self, hge_ctx):
|
|
|
|
# check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_keys_any_os_operating_system.yaml')
|
|
|
|
|
|
|
|
def test_select_product_jsonb_has_key_sim_type(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/select_product_jsonb_has_key_sim_type.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/v1/select/boolexp/jsonb'
|
|
|
|
|
|
|
|
class TestV1SelectBoolExpPostGIS(DefaultTestSelectQueries):
|
|
|
|
|
|
|
|
def test_query_st_equals(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_st_equals.yaml')
|
|
|
|
|
|
|
|
def test_query_st_contains(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_st_contains.yaml')
|
|
|
|
|
|
|
|
def test_query_st_touches(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_st_touches.yaml')
|
|
|
|
|
|
|
|
def test_query_not_st_intersects(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_not_st_intersects.yaml')
|
|
|
|
|
|
|
|
def test_query_st_d_within(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_st_d_within.yaml')
|
|
|
|
|
2019-03-25 15:29:52 +03:00
|
|
|
def test_query_geog_stdwithin(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_geog_stdwithin.yaml')
|
|
|
|
|
|
|
|
def test_query_geog_stdwithin_sph(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_geog_stdwithin_sph.yaml')
|
|
|
|
|
|
|
|
def test_query_geog_stintersects(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/query_geog_stintersects.yaml')
|
|
|
|
|
2019-01-28 20:46:31 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/v1/select/boolexp/postgis'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1SelectPermissions(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
|
|
|
|
2019-01-28 20:46:31 +03:00
|
|
|
def test_user_can_query_geometry_values_filter(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_geometry_values_filter.yaml')
|
|
|
|
|
|
|
|
def test_user_can_query_geometry_values_filter_session_vars(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_geometry_values_filter_session_vars.yaml')
|
|
|
|
|
2019-03-25 15:29:52 +03:00
|
|
|
def test_user_can_query_geog_filter(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_geog_filter.yaml')
|
|
|
|
|
|
|
|
def test_user_can_query_geog_filter_session_vars(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_geog_filter_session_vars.yaml')
|
|
|
|
|
2019-01-28 20:46:31 +03:00
|
|
|
def test_user_can_query_jsonb_values_filter(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_jsonb_values_filter.yaml')
|
|
|
|
|
|
|
|
def test_user_can_query_jsonb_values_filter_session_vars(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/user_can_query_jsonb_values_filter_session_vars.yaml')
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return 'queries/v1/select/permissions'
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1InsertBasic(DefaultTestQueries):
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_insert_author(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/insert_author.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_insert_author_col_not_present_err(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/insert_author_col_not_present_err.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_insert_null_col_value(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/order_col_shipped_null.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/insert/basic"
|
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 TestV1InsertOnConflict(DefaultTestQueries):
|
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_author_on_conflict_update(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/upsert_author.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_on_conflict_no_action_specified(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_on_conflict_no_action_specified.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_on_conflict_ignore(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_on_conflict_ignore_constraint.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_missing_article_constraint(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_on_conflict_error_missing_article_constraint.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_unexpected_action(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_unexpected_on_conflict_action.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_err_unexpected_constraint(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_unexpected_on_conflict_constraint_error.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/insert/onconflict"
|
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 TestV1InsertPermissions(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_role_on_conflict_update(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/article_on_conflict_user_role.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_role_on_conflict_ignore(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_on_conflict_ignore_user_role.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_role_has_no_permissions_err(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/address_permission_error.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_author_user_role_insert_check_perm_success(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_user_role_insert_check_perm_success.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_role_insert_check_is_registered_fail(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_user_role_insert_check_is_registered_fail.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_role_insert_check_user_id_fail(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_user_role_insert_check_user_id_fail.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_student_role_insert_check_bio_success(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_student_role_insert_check_bio_success.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_student_role_insert_check_bio_fail(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_student_role_insert_check_bio_fail.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-12-15 19:10:29 +03:00
|
|
|
def test_resident_1_modifies_resident_2_upsert(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/resident_1_modifies_resident_2_upsert.yaml")
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/insert/permissions"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1UpdateBasic(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_set_author_name(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/author_set_name.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_set_person_details(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/person_set_details.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-30 12:21:58 +03:00
|
|
|
def test_person_id_inc(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/person_inc.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-30 12:21:58 +03:00
|
|
|
def test_product_mul_price(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/product_mul_price.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-30 12:21:58 +03:00
|
|
|
def test_product_set_default_price(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/product_set_default_price.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_no_operator_err(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/person_error_no_operator.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_no_where_clause_err(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/person_error_no_where_clause.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/update/basic"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestV1UpdatePermissions(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_can_update_unpublished_article(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_can_update_unpublished_article.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_cannot_update_published_version_col(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_cannot_update_published_article_version.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_cannot_update_another_users_article(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_cannot_update_another_users_article.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_user_cannot_update_id_col(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_cannot_update_id_col_article.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
|
|
|
|
2019-02-11 15:45:30 +03:00
|
|
|
def test_user_update_resident_preset_error(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_update_resident_preset_error.yaml")
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
|
|
|
|
|
|
|
def test_user_update_resident_preset(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_update_resident_preset.yaml")
|
|
|
|
|
|
|
|
def test_user_update_resident_preset_session_var(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + "/user_update_resident_preset_session_var.yaml")
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/update/permissions"
|
|
|
|
|
|
|
|
|
|
|
|
class TestV1CountBasic(DefaultTestSelectQueries):
|
|
|
|
|
|
|
|
def test_count_authors(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_authors.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_published_articles(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_published_articles.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_unpublished_articles(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_unpublished_articles.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_distinct_authors_with_published_articles(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_distinct_authors_with_published_articles.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
def test_count_articles_registered_authors(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_articles_with_registered_authors.yaml")
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
def test_count_articles_non_registered_authors(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_articles_with_non_registered_authors.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_distinct_col_not_present_err(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_distinct_col_not_present_err.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_distinct_authors_with_unpublished_articles(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_distinct_authors_with_unpublished_articles.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/count/basic"
|
|
|
|
|
|
|
|
|
|
|
|
class TestV1CountPermissions(DefaultTestSelectQueries):
|
|
|
|
|
|
|
|
def test_count_user_has_no_select_permission_err(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_user_has_no_select_perm_error.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
def test_count_other_users_unpublished_articles(self, hge_ctx):
|
2018-10-30 12:21:58 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + "/count_users_unpublished_articles.yaml")
|
2018-10-28 21:27:49 +03:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/count/permissions"
|
|
|
|
|
|
|
|
|
|
|
|
class TestV1Delete(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-09-18 09:21:57 +03:00
|
|
|
def test_delete_author(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/delete_article.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/delete"
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestMetadata(DefaultTestQueries):
|
2018-09-18 09:21:57 +03:00
|
|
|
|
|
|
|
def test_reload_metadata(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/reload_metadata.yaml')
|
2018-09-18 09:21:57 +03:00
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_export_metadata(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/export_metadata.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_clear_metadata(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/clear_metadata.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-11-27 14:26:10 +03:00
|
|
|
def test_replace_metadata(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/replace_metadata.yaml')
|
|
|
|
|
|
|
|
def test_replace_metadata_wo_remote_schemas(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/replace_metadata_wo_rs.yaml')
|
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_dump_internal_state(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/dump_internal_state.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-11-27 14:26:10 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/metadata"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestRunSQL(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_select_query(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_select_query.yaml')
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_set_timezone(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_set_timezone.yaml')
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
def test_sql_timezone_error(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_set_timezone_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_sql_query_as_user_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_query_as_user_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2019-03-01 12:17:22 +03:00
|
|
|
def test_sql_rename_table(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_rename_table.yaml')
|
|
|
|
|
|
|
|
def test_sql_rename_columns(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_rename_columns.yaml')
|
|
|
|
|
|
|
|
def test_sql_rename_table_and_column(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/sql_rename_table_and_column.yaml')
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/run_sql"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestRelationships(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_object_relationship_foreign_key(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/object_relationship_foreign_key.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_create_object_relationship_as_not_admin_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/create_object_relationship_as_not_admin_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_object_relationship_col_not_foreign_key_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/object_relationship_col_not_foreign_key_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_object_relationship_foreign_key_non_public_schema(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/object_relationship_non_public_schema_foreign_key.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_object_relationship_manual(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/object_relationship_manual.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_array_relationship_foreign_key(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/array_relationship_foreign_key.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_create_array_relationship_as_not_admin_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/create_array_relationship_as_not_admin_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_array_relationship_col_not_foreign_key_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/array_relationship_col_not_foreign_key_error.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_array_relationship_foreign_key_non_public_schema(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/array_relationship_non_public_schema_foreign_key.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_array_relationship_manual(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/array_relationship_manual.yaml')
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/relationships"
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
|
2018-10-28 21:27:49 +03:00
|
|
|
class TestTrackTables(DefaultTestQueries):
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_track_untrack_table(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/track_untrack_table.yaml')
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
2019-01-24 16:26:13 +03:00
|
|
|
def test_track_untrack_table_with_deps(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/track_untrack_table_deps.yaml')
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
|
|
|
|
2018-10-04 15:44:15 +03:00
|
|
|
def test_track_untrack_table_non_public_schema(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/track_untrack_table_non_public_schema.yaml')
|
|
|
|
hge_ctx.may_skip_test_teardown = True
|
2018-10-04 15:44:15 +03:00
|
|
|
|
|
|
|
def test_track_untrack_table_as_not_admin_error(self, hge_ctx):
|
2018-10-28 21:27:49 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/track_untrack_table_as_not_admin_error.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/track_table"
|
|
|
|
|
|
|
|
|
|
|
|
class TestCreatePermission(DefaultTestQueries):
|
|
|
|
|
|
|
|
def test_create_permission_admin_role_error(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/create_article_permission_role_admin_error.yaml')
|
|
|
|
|
|
|
|
def test_create_permission_user_role_error(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/create_article_permission_role_user.yaml')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/v1/permissions"
|