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 """Butler data ID of a file to ingest when testing.""" 54 """Full path to a file to ingest in tests.""" 59 Butler.makeRepo(self.
root)
66 self.
config = RawIngestTask.ConfigClass()
68 f
"{self.instrument.__class__.__module__}.{self.instrument.__class__.__name__}" 71 if os.path.exists(self.
root):
72 shutil.rmtree(self.
root, ignore_errors=
True)
76 Initialize and run RawIngestTask on a list of files. 80 files : `list` [`str`], or None 81 List of files to be ingested, or None to use ``self.file`` 86 task.log.setLevel(task.log.FATAL)
91 Test that RawIngestTask ingested the expected files. 95 files : `list` [`str`], or None 96 List of files to be ingested, or None to use ``self.file`` 102 self.assertImagesEqual(exposure.image, image)
103 self.assertEqual(metadata.toDict(), exposure.getMetadata().toDict())
107 """Check the state of the repository after ingest. 109 This is an optional hook provided for subclasses; by default it does 114 files : `list` [`str`], or None 115 List of files to be ingested, or None to use ``self.file`` 120 self.config.transfer =
"symlink" 124 self.
config.transfer =
"copy" 128 self.
config.transfer =
"hardlink" 131 except PermissionError
as err:
132 raise unittest.SkipTest(
"Skipping hard-link test because input data" 133 " is on a different filesystem.")
from err
136 """Test that files already in the directory can be added to the 140 newPath = os.path.join(self.
butler.datastore.root, os.path.basename(self.
file))
141 os.symlink(self.
file, newPath)
142 self.
config.transfer =
None 146 """Re-ingesting the same data into the repository should fail. 148 self.
config.transfer =
"symlink" 150 with self.assertRaises(Exception):
def runIngest(self, files=None)
def runIngestTest(self, files=None)
def checkRepo(self, files=None)
def testFailOnConflict(self)