BaseConfigTestCase

class lsst.ts.salobj.BaseConfigTestCase

Bases: object

Base class for testing configuration files.

Subclasses must:

Also we suggest:

Methods Summary

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_files to 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: str | pathlib.Path, schema: dict[str, Any], exclude_glob: str | None = None) None

Check all configuration files for a given package.

Parameters:
config_dirstr or pathlib.Path

Directory containing config files.

schemadict

Configuration schema.

exclude_override_globdict

Glob expression for files to exclude.

Raises:
AssertionError

If the files do not produce a valid schema.

check_standard_config_files(module_name: str, schema_name: str = 'CONFIG_SCHEMA', sal_name: str | None = None, config_package_root: str | pathlib.Path | None = None, config_dir: str | pathlib.Path | None = None) None

A wrapper around check_config_files to test salobj packages.

Parameters:
module_namestr

Module name, e.g. “lsst.ts.salobj”.

schema_namestr

Name of schema constant in the module, typically “CONFIG_SCHEMA”.

sal_namestr or None

SAL component name, e.g. “Watcher”. Ignored if config_dir is not None. Used to determine config dir if config_dir is None.

config_package_rootstr or pathlib.Path or None

Root directory of configuration package. Used to determine config dir if config_dir is None. Within the unit test for a config package, this will work:

config_package_root = pathlib.Path(__file__).parents[1]

Ignored if config_dir is specified.

config_dirstr or pathlib.Path or None

Directory containing config files. If None then a reasonable value is computed; this is primarily intended to support unit testing in ts_salobj.

exclude_globstr

Glob expression of override files to exclude. For use by salobj unit tests.

get_config_dir(config_package_root: str | pathlib.Path, sal_name: str, schema: dict[str, Any]) Path

Get the directory of config files, assuming the standard ts_config_x package layout.

The config dir is assumed to be as follows, where version comes from the title field of the schema:

config_package_root / sal_name / version

Parameters:
config_package_rootstr or pathlib.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_namestr

SAL component name, e.g. “Watcher”.

schemadict

Configuration schema. Used to determine the version.

Returns:
config_dirpathlib.Path

Directory containing configuration files.

get_schema(csc_package_root: str | pathlib.Path, sal_name: str | None = None, schema_subpath: str | None = None) dict[str, str]

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:
csc_package_rootstr or pathlib.Path

Root directory of CSC package.

sal_namestr

SAL component name, e.g. “Watcher”. Ignored if schema_subpath is specified.

schema_subpathstr or None

Schema path relative to csc_package_root. If None then use f"schema/{sal_name}.yaml"

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.