batconf.sources.tests package
Submodules
batconf.sources.tests.argparse_test module
- class batconf.sources.tests.argparse_test.TestNamespaceConfig(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test___repr__()
- Return type:
None
- test___str__()
- Return type:
None
- test_get()
batconf.sources.tests.args_test module
- class batconf.sources.tests.args_test.TestCliArgsConfig(methodName='runTest')
Bases:
TestCaseFor now Argparse Namespace objects are not nested all args are top-level properties. This should be changed in the future to avoid overriding default values in one module with cli args intended for another
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test_get()
batconf.sources.tests.dataclass_test module
batconf.sources.tests.env_test module
- class batconf.sources.tests.env_test.TestEnvConfig(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test___repr__()
- Return type:
None
- test___str__()
- Return type:
None
- test_env_name()
- test_get()
batconf.sources.tests.file_test module
- class batconf.sources.tests.file_test.FileLoaderFunctionTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_load_file_error_when_missing()
- test_load_file_ignore_when_missing()
- test_load_file_warn_when_missing()
- class batconf.sources.tests.file_test.MissingFileHandlersTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_dispatch()
Calling an entry by key delegates to the correct handler.
- test_keys()
Each key maps to the correct handler function.
batconf.sources.tests.ini_test module
- class batconf.sources.tests.ini_test.GetConfigFunctionsTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test__get_empty()
_get_empty always returns None
- Return type:
None
- test__get_envs()
Gets values from a ConfigParser which uses batconf-style environment sections
- test__get_flat()
Flat files contain no sections * a default ‘root’ section is injected into the ConfigParser So only single-key lookups are valid… however keys can be delimited with ‘.’
- This is valid flat formatted config.ini contents:
section.key=value section.key2=value2 section.subsection.key=value3
- test__get_sections()
Get values from a ConfigParser which has sections but does not use batconf-style environment sections. This is for the standard .ini file format.
- Return type:
None
- class batconf.sources.tests.ini_test.GlobalsTests(methodName='runTest')
Bases:
TestCasetest global variables in this test file
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test_CONFIG_PARSER_ENVS()
Test some assumptions we rely on about how ConfigParser functions
- test_CONFIG_PARSER_ENVS_contains_all_environments()
- test_ConfigParser_is_not_nested()
- test_get_batconf_default_env()
- test_get_value_from_dev_environment()
- test_get_value_from_dev_environment_subsection()
- test_get_value_from_prod_environment()
- class batconf.sources.tests.ini_test.IniConfigTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test___init__()
- test___init___with_config_env()
- test_is_IniSource_subclass()
- class batconf.sources.tests.ini_test.IniSourceTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test___init__()
- test___init__catches_invalid_file_format()
- test___repr__()
- Return type:
None
- test___str__()
- Return type:
None
- test__config_env()
- test__data()
- test__file_format()
- test__get_impl()
- test__loader()
- test_get()
get() delegates to _get_impl
- test_get_legacy_path_parameter()
batconf.sources.tests.toml_test module
- class batconf.sources.tests.toml_test.DeprecationTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test_TomlConfig_is_TomlSource_subclass()
- class batconf.sources.tests.toml_test.ImportTomlLoadFunctionTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test__import_toml_load_function_missing_toml_module()
The toml module is an optional extra, not required to use batconf after Python version 3.11. Using batconf without toml should not raise any Errors, But attempting to use TomlConfig when it is not installed will raise an ImportError on older versions of python without tomllib.
- test__import_toml_load_function_with_toml()
- test__import_toml_load_function_with_tomllib()
- class batconf.sources.tests.toml_test.TomlLoaderFunctionsTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test__load_toml()
Test the _load_toml function default behavior
- test__load_toml__FileNotFoundError(_load_toml_file)
- Parameters:
_load_toml_file (
Mock)
- test__load_toml__when_missing_option()
Test that calling the _load_toml function with when_missing=’error’ calls the _load_file_error_when_missing function.
- test__load_toml_file()
- class batconf.sources.tests.toml_test.TomlSourceTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test___init__defaults()
- test___repr__()
- Return type:
None
- test___str__()
- Return type:
None
- test__config_env()
- test__data()
_raw_data is injected directly to bypass lazy file loading; tests _data’s slicing logic.
- test_config_env_argument()
- test_get()
Trying to get a section value returns None, not a dict
- test_get__from_env()
- Return type:
None
- test_get__from_sections()
- test_keys()
- test_missing_file_warning()
Default behavior. Missing config files result in a warning. And the loaded _data is empty
batconf.sources.tests.types_test module
Verify the public batconf.sources.types namespace.
- class batconf.sources.tests.types_test.SourcesTypesTests(methodName='runTest')
Bases:
TestCaseVerify all intended symbols are importable from batconf.sources.types.
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- test_all_is_complete()
Every symbol in __all__ must be importable from batconf.sources.types.
- test_deprecated_names()
Old Proto-suffixed names emit DeprecationWarning but still resolve.
- test_protocols()
- test_type_aliases()
batconf.sources.tests.yaml_test module
- class batconf.sources.tests.yaml_test.YamlConfigDeprecationTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_enable_config_environments_maps_to_file_format()
- class batconf.sources.tests.yaml_test.YamlConfigTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- get_file_path: Mock
- setUp()
Hook method for setting up the test fixture before exercising it.
- test___init__()
- test___repr__()
- Return type:
None
- test___str__()
- Return type:
None
- test__data()
- test__file_format()
- test__getitem__()
- test_config_env_argument()
- test_disable_config_environments()
The default behavior for the configuration file allows it to contain separate configurations for different environments. This behavior may be disabled if desired.
- test_get()
- Return type:
None
- test_keys()
- test_loads_given_config_file(_data_prop)
- Parameters:
_data_prop (
Mock)
- test_missing_file_warning()
Default behavior. Missing config files result in a warning.
- class batconf.sources.tests.yaml_test.YamlLoaderFunctionsTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test__load_yaml()
Default behavior: file is found and loaded.
- test__load_yaml__error(_load_yaml_file)
- Parameters:
_load_yaml_file (
Mock)
- test__load_yaml__when_missing_option()
Dispatches to the correct handler with the right arguments.
- test__load_yaml_file()
- test__load_yaml_file_missing_pyyaml_module()
The pyyaml module is an optional extra, not required to use this package. Using the module without pyyaml should not raise any Errors, But attempting to use YamlConfig when it is not installed will raise an ImportError.
- class batconf.sources.tests.yaml_test.YamlSourceTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- setUp()
Hook method for setting up the test fixture before exercising it.
- test___init__()
- test___repr__()
- test___str__()
- test__config_env()
- test__data()
_raw_data is injected directly to bypass lazy file loading; tests _data’s slicing logic.
- test_config_env_argument()
- test_get()
- test_keys()
- class batconf.sources.tests.yaml_test.get_file_pathTests(methodName='runTest')
Bases:
TestCaseCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- Path: Mock
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_absolute_path()
when the absolute path exists, return it
- test_missing_error()
file path does not exist, missing_file_option=”error” Setting _config_file_name to an invalid path should raise a FileNotFound error
- test_missing_ignore()
- test_missing_warning(log)
file path does not exist, default=warn
- Parameters:
log (
Mock)
- test_relative_path()
When the relative path exists, return it