BaseConfigTestCase#

class lsst.ts.salobj.BaseConfigTestCase#

Bases: object

Base class for testing configuration files.

Subclasses must:

Also we suggest:

Methods Summary

asyncTearDown()

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_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

async asyncTearDown()#

Runs after each test is completed.

Return type:

None

check_config_files(config_dir, schema, exclude_glob=None)#

Check all configuration files for a given package.

Parameters:
  • config_dir (str or pathlib.Path) – Directory containing config files.

  • schema (dict) – Configuration schema.

  • exclude_override_glob (dict) – Glob expression for files to exclude.

  • exclude_glob (str | None, default: None)

Raises:

AssertionError – If the files do not produce a valid schema.

Return type:

None

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_files to 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 (str 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_root (str 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_dir (str 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_glob (str) – Glob expression of override files to exclude. For use by salobj unit tests.

Return type:

None

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 version comes from the title field of the schema:

config_package_root / sal_name / version

Parameters:
  • config_package_root (str 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_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:

pathlib.Path

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:
  • csc_package_root (str or pathlib.Path) – Root directory of CSC package.

  • sal_name (str) – SAL component name, e.g. “Watcher”. Ignored if schema_subpath is specified.

  • schema_subpath (str 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.

Return type:

dict[str, str]