22 """Base class for writing Gen3 raw data ingest tests. 25 __all__ = (
"IngestTestBase",)
33 from lsst.daf.butler
import Butler
38 """Base class for tests of gen3 ingest. Subclass from this, then 39 `unittest.TestCase` to get a working test suite. 43 """Root path to ingest files into. Typically `obs_package/tests/`; the 44 actual directory will be a tempdir under this one. 48 """The instrument to be registered and tested.""" 51 """list of butler data IDs of files that should have been ingested.""" 54 """Full path to a file to ingest in tests.""" 57 """The task to use in the Ingest test.""" 62 Butler.makeRepo(self.
root)
71 f
"{self.instrument.__class__.__module__}.{self.instrument.__class__.__name__}" 74 if os.path.exists(self.
root):
75 shutil.rmtree(self.
root, ignore_errors=
True)
79 Initialize and run RawIngestTask on a list of files. 83 files : `list` [`str`], or None 84 List of files to be ingested, or None to use ``self.file`` 89 task.log.setLevel(task.log.FATAL)
94 Test that RawIngestTask ingested the expected files. 98 files : `list` [`str`], or None 99 List of files to be ingested, or None to use ``self.file`` 102 datasets = self.
butler.registry.queryDatasets(
'raw', collections=...)
103 self.assertEqual(len(list(datasets)), len(self.
dataIds))
105 exposure = self.
butler.get(
"raw", dataId)
106 metadata = self.
butler.get(
"raw.metadata", dataId)
108 self.assertEqual(metadata.toDict(), exposure.getMetadata().toDict())
112 """Check the state of the repository after ingest. 114 This is an optional hook provided for subclasses; by default it does 119 files : `list` [`str`], or None 120 List of files to be ingested, or None to use ``self.file`` 125 self.config.transfer =
"symlink" 129 self.
config.transfer =
"copy" 133 self.
config.transfer =
"hardlink" 136 except PermissionError
as err:
137 raise unittest.SkipTest(
"Skipping hard-link test because input data" 138 " is on a different filesystem.")
from err
141 """Test that files already in the directory can be added to the 145 newPath = os.path.join(self.
butler.datastore.root, os.path.basename(self.
file))
146 os.symlink(os.path.abspath(self.
file), newPath)
147 self.
config.transfer =
None 151 """Re-ingesting the same data into the repository should fail. 153 self.
config.transfer =
"symlink" 155 with self.assertRaises(Exception):
def runIngest(self, files=None)
def runIngestTest(self, files=None)
def checkRepo(self, files=None)
def testFailOnConflict(self)