2022-05-26 14:54:30 +03:00
|
|
|
import pytest
|
2022-12-21 18:55:24 +03:00
|
|
|
|
|
|
|
from validate import check_query_f
|
2022-05-26 14:54:30 +03:00
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
2022-05-26 14:54:30 +03:00
|
|
|
class TestNamingConventions:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
|
2022-05-26 14:54:30 +03:00
|
|
|
def test_field_name_precedence(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/field_name_precedence.yaml')
|
2022-07-05 15:36:17 +03:00
|
|
|
|
2022-05-26 14:54:30 +03:00
|
|
|
def test_enum_value_convention(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/enum_value_convention.yaml')
|
2022-07-05 15:36:17 +03:00
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
class TestNamingConventionsTypeAndFieldNamesGraphqlDefault:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
def test_type_and_field_names(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_graphql_default.yaml')
|
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
class TestNamingConventionsTypeAndFieldNamesHasuraDefault:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={'naming_convention': 'hasura-default'})
|
|
|
|
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
def test_type_and_field_names(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_hasura_default.yaml')
|
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
class TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={
|
|
|
|
'naming_convention': 'graphql-default',
|
|
|
|
'root_fields': {
|
|
|
|
'prefix': 'test',
|
|
|
|
'suffix': 'query',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
def test_type_and_field_names_with_prefix_and_suffix(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_graphql_default_with_prefix_and_suffix.yaml')
|
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
class TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={
|
|
|
|
'naming_convention': 'hasura-default',
|
|
|
|
'root_fields': {
|
|
|
|
'prefix': 'test_',
|
|
|
|
'suffix': '_query',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2022-07-05 15:36:17 +03:00
|
|
|
def test_type_and_field_names_with_prefix_and_suffix(self, hge_ctx):
|
server/tests-py: Split the naming convention tests.
This splits two naming convention tests into four classes (and four YAML
files), which might seem overkill, but allows us to provision sources
declaratively in the future. As each class will require a custom source
configuration, we are able to annotate them accordingly, which means the
test cases are decoupled from the source database URL, letting us
generate a new database for each test case and automatically add it as a
source to HGE.
The future changes are already prepared, but this has been extracted out
as it splits the YAML files, which is a large change best reviewed in
isolation.
The test case `test_type_and_field_names` has been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefault`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefault`
The test case `test_type_and_field_names_with_prefix_and_suffix` has
been split into:
* `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix`
* `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix`
The YAML files have been split in the same way. This was fairly trivial
as each test case would add a source, run some tests with
the `graphql_default` naming convention, drop the source, and then
repeat for the `hasura_default` naming convention. I simply split the
file in two. There is a little bit of duplication for provisioning the
various database tables, which I think is worth it.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496
GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
2022-08-17 07:35:03 +03:00
|
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_hasura_default_with_prefix_and_suffix.yaml')
|
2022-05-26 14:54:30 +03:00
|
|
|
|
2022-08-02 22:32:46 +03:00
|
|
|
@pytest.mark.backend('mssql')
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
2022-05-26 14:54:30 +03:00
|
|
|
class TestNamingConventionsFailure:
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
2022-07-05 15:36:17 +03:00
|
|
|
|
2022-05-26 14:54:30 +03:00
|
|
|
def test_other_than_pg_db_failure(self, hge_ctx):
|
2022-12-21 18:55:24 +03:00
|
|
|
response = hge_ctx.v1metadataq(
|
|
|
|
q={
|
|
|
|
"type": "mssql_add_source",
|
|
|
|
"args": {
|
|
|
|
"name": "mssql_naming_conventions_db",
|
|
|
|
"configuration": {
|
|
|
|
"connection_info": {
|
|
|
|
"connection_string": {
|
|
|
|
"from_env": "HASURA_GRAPHQL_MSSQL_SOURCE_URL",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"customization": {
|
|
|
|
"naming_convention": "graphql-default",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
expected_status_code=400,
|
|
|
|
)
|
|
|
|
assert response == {
|
|
|
|
"code": "not-supported",
|
|
|
|
"path": "$.args",
|
|
|
|
"error": "sources other than postgres do not support graphql-default as naming convention yet",
|
|
|
|
}
|
2022-05-26 14:54:30 +03:00
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_DEFAULT_NAMING_CONVENTION', 'graphql-default')
|
2022-05-26 14:54:30 +03:00
|
|
|
class TestDefaultNamingConvention:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
2022-07-05 15:36:17 +03:00
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_another_source(self, add_source):
|
|
|
|
add_source('pg1')
|
|
|
|
|
2022-05-26 14:54:30 +03:00
|
|
|
def test_default_global_naming_convention(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/default_global_naming_convention.yaml')
|
2022-06-30 08:55:50 +03:00
|
|
|
|
2022-09-28 12:19:47 +03:00
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', None) # must be unset
|
2022-06-30 08:55:50 +03:00
|
|
|
class TestNamingConventionWithoutExperimentalFeature:
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def dir(cls):
|
|
|
|
return "queries/naming_conventions"
|
2022-07-05 15:36:17 +03:00
|
|
|
|
2022-12-21 18:55:24 +03:00
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
|
|
def add_customized_source(self, add_source):
|
|
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
|
2022-06-30 08:55:50 +03:00
|
|
|
def test_naming_convention_without_feature_turned_on(self, hge_ctx):
|
|
|
|
check_query_f(hge_ctx, self.dir() + '/naming_convention_without_feature_turned_on.yaml')
|