graphql-engine/server/tests-py/test_naming_conventions.py
Samir Talwar 8cb2738cbe server/tests-py: Declaratively state the HGE environment variables.
This has two purposes:

* When running the Python integration tests against a running HGE instance, with `--hge-url`, it will check the environment variables available and actively skip the test if they aren't set. This replaces the previous ad-hoc skip behavior.
* More interestingly, when running against a binary with `--hge-bin`, the environment variables are passed through, which means different tests can run with different environment variables.

  On top of this, the various services we use for testing now also provide their own environment variables, rather than expecting a test script to do it.

In order to make this work, I also had to invert the dependency between various services and `hge_ctx`. I extracted a `pg_version` fixture to provide the PostgreSQL version, and now pass the `hge_url` and `hge_key` explicitly to `ActionsWebhookServer`.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6028
GitOrigin-RevId: 16d866741dba5887da1adf4e1ade8182ccc9d344
2022-09-28 09:21:02 +00:00

88 lines
3.1 KiB
Python

import ruamel.yaml as yaml
from validate import check_query_f
import pytest
import os
@pytest.mark.hge_env('HASURA_GRAPHQL_EXPERIMENTAL_FEATURES', 'naming_convention')
class TestNamingConventions:
@classmethod
def dir(cls):
return "queries/naming_conventions"
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"
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"
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"
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"
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')
class TestNamingConventionsFailure:
@classmethod
def dir(cls):
return "queries/naming_conventions"
def test_other_than_pg_db_failure(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/mssql_naming_convention.yaml')
@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"
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"
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')