Coverage for tests/test_workspace.py : 36%

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/>. #
self._testWorkspace = tempfile.mkdtemp() self._testbed = Workspace(self._testWorkspace)
shutil.rmtree(self._testWorkspace, ignore_errors=True)
"""Test that ``path`` is a subpath of ``baseDir``. """ _canonPath = os.path.abspath(os.path.realpath(path)) _canonDir = os.path.abspath(os.path.realpath(baseDir)) ancestor = os.path.commonprefix([_canonPath, _canonDir]) self.assertEqual(ancestor, _canonDir)
"""Test that ``path`` is a subpath of ``baseDir``. """ _canonPath = os.path.abspath(os.path.realpath(path)) _canonDir = os.path.abspath(os.path.realpath(baseDir)) ancestor = os.path.commonprefix([_canonPath, _canonDir]) self.assertNotEqual(ancestor, _canonDir)
"""Verify that a Workspace creates the workspace directory if it does not exist. """ newPath = '_temp' shutil.rmtree(newPath, ignore_errors=True) self.assertFalse(os.path.exists(newPath), 'Workspace directory must not exist before test.')
try: Workspace(newPath) self.assertTrue(os.path.exists(newPath), 'Workspace directory must exist.') finally: shutil.rmtree(newPath, ignore_errors=True)
def _allRepos(workspace): """An iterator over all repos exposed by a Workspace. """ yield workspace.dataRepo yield workspace.calibRepo yield workspace.templateRepo yield workspace.outputRepo
"""Verify that a Workspace creates repositories in the target directory.
The exact repository locations are not tested, as they are likely to change. """ root = self._testWorkspace self._assertInDir(self._testbed.configDir, root) for repo in WorkspaceTestSuite._allRepos(self._testbed): # Workspace spec allows these to be URIs or paths, whatever the Butler accepts self._assertInDir(url2pathname(repo), root)
"""Verify that a Workspace requests a database file in the target directory, but not in any repository. """ root = self._testWorkspace self._assertInDir(self._testbed.dbLocation, root) for repo in WorkspaceTestSuite._allRepos(self._testbed): # Workspace spec allows these to be URIs or paths, whatever the Butler accepts self._assertNotInDir(self._testbed.dbLocation, url2pathname(repo))
lsst.utils.tests.init()
lsst.utils.tests.init() unittest.main() |