Skip to content

Commit

Permalink
TDD - Duplicate a set of test that are expected to be failed
Browse files Browse the repository at this point in the history
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam committed Nov 15, 2023
1 parent aeb7da3 commit fa67190
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tests/config/test_omegaconf_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _create_config_dir(request, tmp_path, base_config, local_config):
_create_config_dir, params=["nested", "flat"], name="create_config_dir_all"
)
use_config_dir = pytest.mark.usefixtures("create_config_dir")
use_config_dir_all = pytest.mark.usefixtures("use_config_dir_all")
use_config_dir_all = pytest.mark.usefixtures("create_config_dir_all")
use_proj_catalog = pytest.mark.usefixtures("proj_catalog")
use_credentials_env_variable_yml = pytest.mark.usefixtures(
"proj_credentials_env_variable"
Expand All @@ -171,7 +171,7 @@ def _create_config_dir(request, tmp_path, base_config, local_config):


class TestOmegaConfigLoader:
@use_config_dir
@use_config_dir_all
def test_load_core_config_dict_syntax(self, tmp_path):
"""Make sure core config can be fetched with a dict [] access."""
conf = OmegaConfigLoader(str(tmp_path))
Expand All @@ -181,7 +181,7 @@ def test_load_core_config_dict_syntax(self, tmp_path):
assert params["param1"] == 1
assert catalog["trains"]["type"] == "MemoryDataset"

@use_config_dir
@use_config_dir_all
def test_load_core_config_get_syntax(self, tmp_path):
"""Make sure core config can be fetched with .get()"""
conf = OmegaConfigLoader(str(tmp_path))
Expand All @@ -191,7 +191,7 @@ def test_load_core_config_get_syntax(self, tmp_path):
assert params["param1"] == 1
assert catalog["trains"]["type"] == "MemoryDataset"

@use_config_dir
@use_config_dir_all
def test_load_local_config_overrides_base(self, tmp_path):
"""Make sure that configs from `local/` override the ones
from `base/`"""
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_nested(self, tmp_path):
assert catalog["cars"]["save_args"]["index"] is True
assert catalog["nested"]["type"] == "MemoryDataset"

@use_config_dir
@use_config_dir_all
def test_nested_subdirs_duplicate(self, tmp_path, base_config):
"""Check the error when the configs from subdirectories contain
duplicate keys"""
Expand All @@ -264,7 +264,7 @@ def test_nested_subdirs_duplicate(self, tmp_path, base_config):
with pytest.raises(ValueError, match=pattern):
OmegaConfigLoader(str(tmp_path))["catalog"]

@use_config_dir
@use_config_dir_all
def test_multiple_nested_subdirs_duplicates(
self, tmp_path, base_config, local_config
):
Expand Down Expand Up @@ -298,7 +298,7 @@ def test_multiple_nested_subdirs_duplicates(
assert re.search(pattern_catalog_local, str(exc.value))
assert re.search(pattern_nested_local, str(exc.value))

@use_config_dir
@use_config_dir_all
def test_bad_config_syntax(self, tmp_path):
conf_path = tmp_path / _BASE_ENV
conf_path.mkdir(parents=True, exist_ok=True)
Expand All @@ -322,7 +322,7 @@ def test_lots_of_duplicates(self, tmp_path):
with pytest.raises(ValueError, match=pattern):
conf["catalog"]

@use_config_dir
@use_config_dir_all
def test_same_key_in_same_dir(self, tmp_path, base_config):
"""Check the error if 2 files in the same config dir contain
the same top-level key"""
Expand All @@ -337,15 +337,15 @@ def test_same_key_in_same_dir(self, tmp_path, base_config):
with pytest.raises(ValueError, match=pattern):
OmegaConfigLoader(str(tmp_path))["catalog"]

@use_config_dir
@use_config_dir_all
def test_pattern_key_not_found(self, tmp_path):
"""Check the error if no config files satisfy a given pattern"""
key = "non-existent-pattern"
pattern = f"No config patterns were found for '{key}' in your config loader"
with pytest.raises(KeyError, match=pattern):
OmegaConfigLoader(str(tmp_path))[key]

@use_config_dir
@use_config_dir_all
def test_cannot_load_non_yaml_or_json_files(self, tmp_path):
db_patterns = {"db": ["db*"]}
db_config_path = tmp_path / _BASE_ENV / "db.ini"
Expand All @@ -362,7 +362,7 @@ def test_cannot_load_non_yaml_or_json_files(self, tmp_path):
with pytest.raises(MissingConfigException, match=pattern):
conf["db"]

@use_config_dir
@use_config_dir_all
def test_no_files_found(self, tmp_path):
"""Check the error if no config files satisfy a given pattern"""
pattern = (
Expand Down Expand Up @@ -515,7 +515,7 @@ def test_unsupported_merge_strategy(self, tmp_path, mlflow_config):
merge_strategy={"mlflow": "hard"},
)["mlflow"]

@use_config_dir
@use_config_dir_all
def test_adding_extra_keys_to_confloader(self, tmp_path):
"""Make sure extra keys can be added directly to the config loader instance."""
conf = OmegaConfigLoader(str(tmp_path))
Expand All @@ -525,7 +525,7 @@ def test_adding_extra_keys_to_confloader(self, tmp_path):
assert catalog["trains"]["type"] == "MemoryDataset"
assert conf["spark"] == {"spark_config": "emr.blabla"}

@use_config_dir
@use_config_dir_all
def test_bypass_catalog_config_loading(self, tmp_path):
"""Make sure core config loading can be bypassed by setting the key and values
directly on the config loader instance."""
Expand All @@ -534,7 +534,7 @@ def test_bypass_catalog_config_loading(self, tmp_path):

assert conf["catalog"] == {"catalog_config": "something_new"}

@use_config_dir
@use_config_dir_all
@use_credentials_env_variable_yml
def test_load_credentials_from_env_variables(self, tmp_path):
"""Load credentials from environment variables"""
Expand All @@ -544,7 +544,7 @@ def test_load_credentials_from_env_variables(self, tmp_path):
assert conf["credentials"]["user"]["name"] == "test_user"
assert conf["credentials"]["user"]["key"] == "test_key"

@use_config_dir
@use_config_dir_all
@use_catalog_env_variable_yml
def test_env_resolver_not_used_for_catalog(self, tmp_path):
"""Check that the oc.env resolver is not used for catalog loading"""
Expand All @@ -553,7 +553,7 @@ def test_env_resolver_not_used_for_catalog(self, tmp_path):
with pytest.raises(errors.UnsupportedInterpolationType):
conf["catalog"]["test"]["file_path"]

@use_config_dir
@use_config_dir_all
@use_credentials_env_variable_yml
def test_env_resolver_is_cleared_after_loading(self, tmp_path):
"""Check that the ``oc.env`` resolver is cleared after loading credentials
Expand All @@ -564,7 +564,7 @@ def test_env_resolver_is_cleared_after_loading(self, tmp_path):
assert conf["credentials"]["user"]["name"] == "test_user"
assert not OmegaConf.has_resolver("oc.env")

@use_config_dir
@use_config_dir_all
@use_credentials_env_variable_yml
def test_env_resolver_is_registered_after_loading(self, tmp_path):
"""Check that the ``oc.env`` resolver is registered after loading credentials
Expand All @@ -577,7 +577,7 @@ def test_env_resolver_is_registered_after_loading(self, tmp_path):
assert OmegaConf.has_resolver("oc.env")
OmegaConf.clear_resolver("oc.env")

@use_config_dir
@use_config_dir_all
def test_load_config_from_tar_file(self, tmp_path):
subprocess.run( # noqa: PLW1510
[
Expand All @@ -594,7 +594,7 @@ def test_load_config_from_tar_file(self, tmp_path):
catalog = conf["catalog"]
assert catalog["trains"]["type"] == "MemoryDataset"

@use_config_dir
@use_config_dir_all
def test_load_config_from_zip_file(self, tmp_path):
def zipdir(path, ziph):
# This is a helper method to zip up a directory without keeping the complete directory
Expand All @@ -618,22 +618,22 @@ def zipdir(path, ziph):
catalog = conf["catalog"]
assert catalog["trains"]["type"] == "MemoryDataset"

@use_config_dir
@use_config_dir_all
def test_variable_interpolation_with_correct_env(self, tmp_path):
"""Make sure the parameters is interpolated with the correct environment"""
conf = OmegaConfigLoader(str(tmp_path))
params = conf["parameters"]
# Making sure it is not override by local/parameters_global.yml
assert params["interpolated_param"] == "base"

@use_config_dir
@use_config_dir_all
def test_runtime_params_override_interpolated_value(self, tmp_path):
"""Make sure interpolated value is updated correctly with runtime_params"""
conf = OmegaConfigLoader(str(tmp_path), runtime_params={"test_env": "dummy"})
params = conf["parameters"]
assert params["interpolated_param"] == "dummy"

@use_config_dir
@use_config_dir_all
@use_credentials_env_variable_yml
def test_runtime_params_not_propogate_non_parameters_config(self, tmp_path):
"""Make sure `catalog`, `credentials`, `logging` or any config other than
Expand Down

0 comments on commit fa67190

Please sign in to comment.