Coverage for tests/test_UrnPolicyFile_1.py : 82%

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
#!/usr/bin/env python # # LSST Data Management System # Copyright 2008, 2009, 2010 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # 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 LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# TODO: test cross-package loading more thoroughly -- mix up the packages and # repositories in a deeply nested and linked policy file.
""" Expect callableObj(args, kwargs) to raise an exception of type excClass, and carres a message that contains excMsg.
excClass: the subclass of LsstCppException we expect to see excMsg: a substring of the message it should carry callableObj: the thing that, when called, should raise an exception failMsg: the assertion message if this fails args, kwargs (optional): arguments to pass to callableObj """ failMsg + ": expected to see the message \"" + excMsg + "\"; actual message was \"" + str(e) + "\".") else: self.fail(failMsg + ": did not raise " + excClass)
if not self.examplesDir: # XXX is this really the best way to find the src_dir? pexPolicyDir = lsst.utils.getPackageDir('pex_policy') self.examplesDir = os.path.join(pexPolicyDir, "examples") if filename: return os.path.join(self.examplesDir, filename) else: return self.examplesDir
Policy, "URN too short", "urn:eupspkg:foo.paf") Policy, "URN abbrev '@' not allowed in constructor", "@pex_policy:tests/urn:level_1.paf")
Policy.createPolicyFromUrn, "doesn't support loading undecorated DictionaryFile", urn) # make sure all reference types worked # self.assertEqual(p.get("indirect.string_type"), "foo") # self.assertEqual(p.get("indirect2.string_type"), "foo")
UrnPolicyFile(base + "1.paf").load, "Typo in URN", Policy()) UrnPolicyFile(base + "2.paf").load, "Typo in URN", Policy())
# when the repository is mis-specified, local files cannot be loaded # we expect it to look in <package>/tests/simple.paf "failure opening Policy file: " + expectedFile, upf.load, "Wrong repository dir.", Policy())
# a PAF file designed to have "tests" as it repository
lsst.utils.tests.init() unittest.main() |