BaseConfigTestCase¶
- class lsst.ts.salobj.BaseConfigTestCase¶
- Bases: - object- Base class for testing configuration files. - Subclasses must: - Inherit both from this and - unittest.TestCase.
 - Also we suggest: - Add a method - test_<foo>which calls- check_config_files.
 - 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_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: str | Path, schema: dict[str, Any], exclude_glob: str | None = None) None¶
- Check all configuration files for a given package. - Parameters:
- config_dirstrorpathlib.Path
- Directory containing config files. 
- schemadict
- Configuration schema. 
- exclude_override_globdict
- Glob expression for files to exclude. 
 
- config_dir
- 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 | Path | None = None, config_dir: str | Path | None = None) None¶
- A wrapper around - check_config_filesto 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_namestrorNone
- SAL component name, e.g. “Watcher”. Ignored if - config_diris not None. Used to determine config dir if- config_diris None.
- config_package_rootstrorpathlib.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_dirstrorpathlib.PathorNone
- Directory containing config files. If - Nonethen 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. 
 
- module_name
 
 - get_config_dir(config_package_root: str | 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 - versioncomes from the title field of the schema:- config_package_root / sal_name / version - Parameters:
- config_package_rootstrorpathlib.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. 
 
- config_package_root
- Returns:
- config_dirpathlib.Path
- Directory containing configuration files. 
 
- config_dir
 
 - get_schema(csc_package_root: str | 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:
- 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.