mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
204ec89c61
This rewrites the last couple of Python tests that were failing when run with a separate HGE binary per test class. The changes are as follows: 1. The event triggers tests, naming conventions tests, and subscriptions tests all generate a new source DB per test, so can run in parallel. 2. The scheduled triggers tests use the correct URL for the trigger service when the port is generated randomly. 3. Whitespace and trailing commas are added to the scheduled triggers tests. 4. Support for SQL Server is added to _hge.py_ so the naming conventions test that runs on SQL Server passes. (The other SQL Server tests do not pass and we're not going to bother with them for now.) 5. Container names are fixed in _run.sh_. 6. _run.sh_ and _run-new.sh_ don't pull images explicitly as it's annoying when running tests a lot. If you want to pull the latest versions, just run `docker compose pull` from the _server/tests-py_ directory, or the root directory. (If you don't have the images at all, they'll still be pulled automatically.) PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7350 GitOrigin-RevId: db58f310f017b2a0884fcf61ccc56d15583f99bd
151 lines
5.4 KiB
Python
151 lines
5.4 KiB
Python
import pytest
|
|
|
|
from validate import check_query_f
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventions:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
def add_customized_source(self, add_source):
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
def test_field_name_precedence(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/field_name_precedence.yaml')
|
|
|
|
def test_enum_value_convention(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/enum_value_convention.yaml')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventionsTypeAndFieldNamesGraphqlDefault:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
def add_customized_source(self, add_source):
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
def test_type_and_field_names(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_graphql_default.yaml')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventionsTypeAndFieldNamesHasuraDefault:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
def add_customized_source(self, add_source):
|
|
add_source('pg1', customization={'naming_convention': 'hasura-default'})
|
|
|
|
def test_type_and_field_names(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_hasura_default.yaml')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@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',
|
|
},
|
|
})
|
|
|
|
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')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@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',
|
|
},
|
|
})
|
|
|
|
def test_type_and_field_names_with_prefix_and_suffix(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/type_and_field_names_hasura_default_with_prefix_and_suffix.yaml')
|
|
|
|
@pytest.mark.backend('mssql')
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
class TestNamingConventionsFailure:
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
def test_other_than_pg_db_failure(self, hge_ctx):
|
|
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",
|
|
}
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_DEFAULT_NAMING_CONVENTION', 'graphql-default')
|
|
class TestDefaultNamingConvention:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
def add_another_source(self, add_source):
|
|
add_source('pg1')
|
|
|
|
def test_default_global_naming_convention(self, hge_ctx):
|
|
check_query_f(hge_ctx, self.dir() + '/default_global_naming_convention.yaml')
|
|
|
|
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', None) # must be unset
|
|
class TestNamingConventionWithoutExperimentalFeature:
|
|
|
|
@classmethod
|
|
def dir(cls):
|
|
return "queries/naming_conventions"
|
|
|
|
@pytest.fixture(scope='class', autouse=True)
|
|
def add_customized_source(self, add_source):
|
|
add_source('pg1', customization={'naming_convention': 'graphql-default'})
|
|
|
|
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')
|