Coverage for tests/test_dataset.py : 32%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # This file is part of ap_verify. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. #
def setUpClass(cls): super().setUpClass()
cls.obsPackage = 'obs_test' cls.camera = 'test'
self._testbed = Dataset(DatasetTestSuite.datasetKey)
"""Verify that a Dataset knows its supported datasets. """ datasets = Dataset.getSupportedDatasets() self.assertIn(DatasetTestSuite.datasetKey, datasets) # assumed by other tests
"""Verify that Dataset construction fails gracefully on unsupported datasets. """ with self.assertRaises(ValueError): Dataset("TotallyBogusDataset")
"""Verify that a Dataset reports the desired directory structure. """ root = self._testbed.datasetRoot self.assertEqual(self._testbed.rawLocation, os.path.join(root, 'raw')) self.assertEqual(self._testbed.calibLocation, os.path.join(root, 'calib')) self.assertEqual(self._testbed.templateLocation, os.path.join(root, 'templates')) self.assertEqual(self._testbed.refcatsLocation, os.path.join(root, 'refcats'))
"""Verify that a Dataset knows its associated obs package and camera. """ self.assertEqual(self._testbed.obsPackage, DatasetTestSuite.obsPackage) self.assertEqual(self._testbed.camera, DatasetTestSuite.camera)
"""Verify that a Dataset can create an output repository as desired. """ testDir = tempfile.mkdtemp() outputDir = os.path.join(testDir, 'goodOut')
try: self._testbed.makeCompatibleRepo(outputDir) self.assertTrue(os.path.exists(outputDir), 'Output directory must exist.') self.assertTrue(os.listdir(outputDir), 'Output directory must not be empty.') self.assertTrue(os.path.exists(os.path.join(outputDir, '_mapper')) or os.path.exists(os.path.join(outputDir, 'repositoryCfg.yaml')), 'Output directory must have a _mapper or repositoryCfg.yaml file.') finally: if os.path.exists(testDir): shutil.rmtree(testDir, ignore_errors=True)
"""Verify that a Dataset can handle pre-existing output directories, including directories made by external code. """ testDir = tempfile.mkdtemp() outputDir = os.path.join(testDir, 'badOut')
try: os.makedirs(outputDir) output = os.path.join(outputDir, 'foo.txt') with open(output, 'w') as dummy: dummy.write('This is a test!')
self._testbed.makeCompatibleRepo(outputDir) self.assertTrue(os.path.exists(outputDir), 'Output directory must exist.') self.assertTrue(os.listdir(outputDir), 'Output directory must not be empty.') self.assertTrue(os.path.exists(os.path.join(outputDir, '_mapper')) or os.path.exists(os.path.join(outputDir, 'repositoryCfg.yaml')), 'Output directory must have a _mapper or repositoryCfg.yaml file.') finally: if os.path.exists(testDir): shutil.rmtree(testDir, ignore_errors=True)
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |