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())
106 self.
config.transfer =
"symlink" 110 self.
config.transfer =
"copy" 114 self.
config.transfer =
"hardlink" 117 except PermissionError
as err:
118 raise unittest.SkipTest(
"Skipping hard-link test because input data" 119 " is on a different filesystem.")
from err
122 """Test that files already in the directory can be added to the 126 newPath = os.path.join(self.
butler.datastore.root, os.path.basename(self.
file))
127 os.symlink(self.
file, newPath)
128 self.
config.transfer =
None 132 """Re-ingesting the same data into the repository should fail. 134 self.
config.transfer =
"symlink" 136 with self.assertRaises(Exception):
def runIngest(self, files=None)
def runIngestTest(self, files=None)
def testFailOnConflict(self)