BaseConfigTestCase#
- class lsst.ts.salobj.BaseConfigTestCase#
Bases:
objectBase class for testing configuration files.
Subclasses must:
Inherit both from this and
unittest.TestCase.
Also we suggest:
Add a method
test_<foo>which callscheck_config_files.
Methods Summary
Runs after each test is completed.
check_config_files(config_dir, schema[, ...])Check all configuration files for a given package.
check_standard_config_files(module_name[, ...])A wrapper around
check_config_filesto test salobj packages.get_config_dir(config_package_root, ...)Get the directory of config files, assuming the standard ts_config_x package layout.
get_schema(csc_package_root[, sal_name, ...])Get the config schema for a package, as a dict.
Methods Documentation
- check_config_files(config_dir, schema, exclude_glob=None)#
Check all configuration files for a given package.
- Parameters:
- Raises:
AssertionError – If the files do not produce a valid schema.
- Return type:
- check_standard_config_files(module_name, schema_name='CONFIG_SCHEMA', sal_name=None, config_package_root=None, config_dir=None)#
A wrapper around
check_config_filesto test salobj packages.- Parameters:
module_name (
str) – Module name, e.g. “lsst.ts.salobj”.schema_name (
str) – Name of schema constant in the module, typically “CONFIG_SCHEMA”.sal_name (
strorNone) – SAL component name, e.g. “Watcher”. Ignored ifconfig_diris not None. Used to determine config dir ifconfig_diris None.config_package_root (
strorpathlib.PathorNone) –Root directory of configuration package. Used to determine config dir if
config_diris None. Within the unit test for a config package, this will work:config_package_root = pathlib.Path(__file__).parents[1]
Ignored if
config_diris specified.config_dir (
strorpathlib.PathorNone) – Directory containing config files. IfNonethen a reasonable value is computed; this is primarily intended to support unit testing in ts_salobj.exclude_glob (str) – Glob expression of override files to exclude. For use by salobj unit tests.
- Return type:
- get_config_dir(config_package_root, sal_name, schema)#
Get the directory of config files, assuming the standard ts_config_x package layout.
The config dir is assumed to be as follows, where
versioncomes from the title field of the schema:config_package_root / sal_name / version
- Parameters:
config_package_root (
strorpathlib.Path) –Root directory of configuration package. For unit tests in a config package, this will work:
config_package_root = pathlib.Path(__file__).parents[1]
sal_name (
str) – SAL component name, e.g. “Watcher”.schema (
dict) – Configuration schema. Used to determine the version.
- Returns:
config_dir – Directory containing configuration files.
- Return type:
- get_schema(csc_package_root, sal_name=None, schema_subpath=None)#
Get the config schema for a package, as a dict.
The schema is expected to be:
csc_package_root / “schema” / f”{sal_name}.yaml”
- Parameters:
- Raises:
AssertionError – If csc_package_root is not an existing directory. If the schema file is not an existing file.
jsonschema.exceptions.SchemaError – If the file cannot be interpreted as a
dict.
- Return type: