Repository: hasura/graphql-engine
File: server/tests-py/test_graphql_mutations.py (Python)

Code before:
    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/permissions"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')
class TestGraphqlInsertConstraints:

    def test_address_not_null_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/address_not_null_constraint_error.yaml")

    def test_insert_unique_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/author_unique_constraint_error.yaml")

    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/constraints"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')
class TestGraphqlInsertNullPrefixedColumnOnConflict:

    def test_address_not_null_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/null_prefixed_column_ok.yaml")

    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/nullprefixcolumn"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@use_mutation_fixtures
class TestGraphqlInsertGeoJson:

    def test_insert_point_landmark(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_landmark.yaml")

    def test_insert_3d_point_drone_loc(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_drone_3d_location.yaml")

    def test_insert_landmark_single_position_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_landmark_single_position_err.yaml")

    def test_insert_line_string_road(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_road.yaml")

    def test_insert_road_single_point_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_road_single_point_err.yaml")


Review comment (suggestion):
I think this could probably have been added to one of the existing insert classes, since we can setup multiple unrelated tables for different tests in one class setup file. I don't think we need to change it now though.

Code after:
    def test_user_insert_account_fail(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/user_insert_account_fail.yaml")

    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/permissions"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')
class TestGraphqlInsertConstraints:

    def test_address_not_null_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/address_not_null_constraint_error.yaml")

    def test_insert_unique_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/author_unique_constraint_error.yaml")

    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/constraints"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')
class TestGraphqlInsertNullPrefixedColumnOnConflict:

    def test_address_not_null_constraint_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/null_prefixed_column_ok.yaml")

    @classmethod
    def dir(cls):
        return "queries/graphql_mutation/insert/nullprefixcolumn"


@pytest.mark.parametrize("transport", ['http', 'websocket'])
@use_mutation_fixtures
class TestGraphqlInsertGeoJson:

    def test_insert_point_landmark(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_landmark.yaml")

    def test_insert_3d_point_drone_loc(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_drone_3d_location.yaml")

    def test_insert_landmark_single_position_err(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_landmark_single_position_err.yaml")

    def test_insert_line_string_road(self, hge_ctx, transport):
        check_query_f(hge_ctx, self.dir() + "/insert_road.yaml")