MockStorageClass¶
- class lsst.pipe.base.tests.mocks.MockStorageClass(original: StorageClass, factory: StorageClassFactory | None = None)¶
- Bases: - StorageClass- A reimplementation of - lsst.daf.butler.StorageClassfor mock datasets.- Parameters:
- originalStorageClass
- The original storage class. 
- factoryStorageClassFactoryorNone, optional
- Storage class factory to use. If - Nonethe default factory is used.
 
- original
 - Notes - Each - MockStorageClassinstance corresponds to a real “original” storage class, with components and conversions that are mocks of the original’s components and conversions. The- pytypefor all- MockStorageClassinstances is- MockDataset.- Attributes Summary - Return the components associated with this - StorageClass.- Return the type converters supported by this - StorageClass.- Class to use to delegate type-specific actions. - Return derived components associated with - StorageClass.- Return - setof names of supported parameters.- Return Python type associated with this - StorageClass.- Methods Summary - Return all defined components. - can_convert(other)- Return - Trueif this storage class can convert python types in the other storage class.- coerce_type(incorrect)- Coerce the supplied incorrect instance to the python type associated with this - StorageClass.- delegate()- Return an instance of a storage class delegate. - filterParameters(parameters[, subset])- Filter out parameters that are not known to this - StorageClass.- get_or_register_mock(original[, factory])- Return a mock storage class for the given original storage class, creating and registering it if necessary. - Return Boolean indicating whether this is a composite or not. - is_type(other[, compare_types])- Return Boolean indicating whether the supplied type matches the type in this - StorageClass.- Return set of all parameters known to this - StorageClass.- mock_dataset_refs(original_refs)- Replace dataset references with versions that uses a mock storage class and dataset type name. - mock_dataset_type(original_type)- Replace a dataset type with a version that uses a mock storage class and name. - unmock_dataset_refs(mock_refs)- Replace dataset references with versions that do not use a mock storage class and dataset type name. - unmock_dataset_type(mock_type)- Replace a mock dataset type with the original one it was created from. - validateInstance(instance)- Check that the supplied Python object has the expected Python type. - validateParameters([parameters])- Check that the parameters are known to this - StorageClass.- Attributes Documentation - components¶
 - converters¶
- Return the type converters supported by this - StorageClass.
 - delegateClass¶
- Class to use to delegate type-specific actions. 
 - derivedComponents¶
 - pytype¶
- Return Python type associated with this - StorageClass.
 - Methods Documentation - allComponents() Mapping[str, MockStorageClass]¶
- Return all defined components. - This mapping includes all the derived and read/write components for the corresponding storage class. 
 - can_convert(other: StorageClass) bool¶
- Return - Trueif this storage class can convert python types in the other storage class.
 - coerce_type(incorrect: Any) Any¶
- Coerce the supplied incorrect instance to the python type associated with this - StorageClass.
 - delegate() StorageClassDelegate¶
- Return an instance of a storage class delegate. - Returns:
- delegateStorageClassDelegate
- Instance of the delegate associated with this - StorageClass. The delegate is constructed with this- StorageClass.
 
- delegate
- Raises:
- TypeError
- This StorageClass has no associated delegate. 
 
 
 - filterParameters(parameters: Mapping[str, Any] | None, subset: Collection | None = None) Mapping[str, Any]¶
- Filter out parameters that are not known to this - StorageClass.- Parameters:
- parametersMapping, optional
- Candidate parameters. Can be - Noneif no parameters have been provided.
- subsetCollection, optional
- Subset of supported parameters that the caller is interested in using. The subset must be known to the - StorageClassif specified. If- Nonethe supplied parameters will all be checked, else only the keys in this set will be checked.
 
- parameters
- Returns:
- Raises:
- ValueError
- Raised if the provided subset is not a subset of the supported parameters or if it is an empty set. 
 
 
 - classmethod get_or_register_mock(original: str, factory: StorageClassFactory | None = None) MockStorageClass¶
- Return a mock storage class for the given original storage class, creating and registering it if necessary. - Parameters:
- originalstr
- Name of the original storage class to be mocked. 
- factoryStorageClassFactory, optional
- Storage class factory singleton instance. 
 
- original
- Returns:
- mockMockStorageClass
- New storage class that mocks - original.
 
- mock
 
 - is_type(other: type, compare_types: bool = False) bool¶
- Return Boolean indicating whether the supplied type matches the type in this - StorageClass.- Parameters:
- Returns:
 - Notes - If this - StorageClasshas not yet imported the Python type the check is done against the full type name, this prevents an attempt to import the type when it will likely not match.
 - knownParameters() set[str]¶
- Return set of all parameters known to this - StorageClass.- The set includes parameters understood by components of a composite. - Returns:
- knownset
- All parameter keys of this - StorageClassand the component storage classes.
 
- known
 
 - static mock_dataset_refs(original_refs: Iterable[DatasetRef]) list[lsst.daf.butler._dataset_ref.DatasetRef]¶
- Replace dataset references with versions that uses a mock storage class and dataset type name. - Parameters:
- original_refsIterable[lsst.daf.butler.DatasetRef]
- Original dataset references to be mocked. 
 
- original_refs
- Returns:
- mock_refslist[lsst.daf.butler.DatasetRef]
- Mocked version of the dataset references, with dataset type name and storage class changed and everything else unchanged. 
 
- mock_refs
 
 - static mock_dataset_type(original_type: DatasetType) DatasetType¶
- Replace a dataset type with a version that uses a mock storage class and name. - Parameters:
- original_typelsst.daf.butler.DatasetType
- Original dataset type to be mocked. 
 
- original_type
- Returns:
- mock_typelsst.daf.butler.DatasetType
- A mock version of the dataset type, with name and storage class changed and everything else unchanged. 
 
- mock_type
 
 - static unmock_dataset_refs(mock_refs: Iterable[DatasetRef]) list[lsst.daf.butler._dataset_ref.DatasetRef]¶
- Replace dataset references with versions that do not use a mock storage class and dataset type name. - Parameters:
- mock_refsIterable[lsst.daf.butler.DatasetRef]
- Dataset references that use a mocked dataset type name and storage class. 
 
- mock_refs
- Returns:
- original_refslist[lsst.daf.butler.DatasetRef]
- The original dataset references. 
 
- original_refs
 
 - static unmock_dataset_type(mock_type: DatasetType) DatasetType¶
- Replace a mock dataset type with the original one it was created from. - Parameters:
- mock_typelsst.daf.butler.DatasetType
- A dataset type with a mocked name and storage class. 
 
- mock_type
- Returns:
- original_typelsst.daf.butler.DatasetType
- The original dataset type. 
 
- original_type
 
 - validateInstance(instance: Any) bool¶
- Check that the supplied Python object has the expected Python type. 
 - validateParameters(parameters: Collection | None = None) None¶
- Check that the parameters are known to this - StorageClass.- Does not check the values. - Parameters:
- parametersCollection, optional
- Collection containing the parameters. Can be - dict-like or- set-like. The parameter values are not checked. If no parameters are supplied, always returns without error.
 
- parameters
- Raises:
- KeyError
- Some parameters are not understood by this - StorageClass.