Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs_test: add tearDown to remove temp test files #35

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 15 additions & 8 deletions tests/testPolicyInRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,22 @@
import lsst.obs.test
import lsst.utils.tests
from lsst.utils import getPackageDir
import shutil


class PolicyTestCase(unittest.TestCase):

"""Tests related to the use of the policy file in Butler/butlerUtils."""
obsTestDir = getPackageDir("obs_test")
testDir = os.path.join(obsTestDir, 'tests', 'PolicyTestCase')
repoARoot = os.path.join(testDir, 'a')

def setUp(self):
self.tearDown()

def tearDown(self):
if os.path.exists(self.testDir):
shutil.rmtree(self.testDir)

def testInRepoPolicyOverrides(self):
"""Verify that the template value specified in the policy file in the repository
Expand All @@ -44,15 +55,11 @@ def testInRepoPolicyOverrides(self):
_policy file.
"""
policyOverride = {'exposures': {'raw': {'template': "raw/v%(visit)d_f%(filter)s.fits.gz"}}}
obsTestDir = getPackageDir("obs_test")
policyPath = os.path.join(obsTestDir, 'policy', 'testMapper.yaml')
policyPath = os.path.join(self.obsTestDir, 'policy', 'testMapper.yaml')
policy = dafPersist.Policy(policyPath)

postISRCCDtemplate = policy.get('exposures.postISRCCD.template')

testDir = os.path.join(obsTestDir, 'tests', 'policyTest')
repoARoot = os.path.join(testDir, 'a')
butler = dafPersist.Butler(outputs={'root': repoARoot,
butler = dafPersist.Butler(outputs={'root': self.repoARoot,
'mapper': lsst.obs.test.TestMapper,
'policy': policyOverride})

Expand All @@ -65,8 +72,8 @@ def testInRepoPolicyOverrides(self):
del butler
del mapper

repoBRoot = os.path.join(testDir, 'b')
butler = dafPersist.Butler(inputs=repoARoot, outputs=repoBRoot)
repoBRoot = os.path.join(self.testDir, 'b')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this together with repoARoot definition for uniformity?

butler = dafPersist.Butler(inputs=self.repoARoot, outputs=repoBRoot)
# check that the reloaded policy got used in the mapper for repo A
mapper = butler._repos.inputs()[0].repo._mapper
self.assertEqual(mapper.mappings['raw'].template, "raw/v%(visit)d_f%(filter)s.fits.gz")
Expand Down