Skip to content

Commit

Permalink
cleanup test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed Feb 27, 2019
1 parent fea32f8 commit 66d4a71
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions py/desitarget/test/test_mock_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestMockBuild(unittest.TestCase):

def setUp(self):
self.outdir = tempfile.mkdtemp()
print('Output directory {}'.format(self.outdir))

def tearDown(self):
if os.path.exists(self.outdir):
Expand All @@ -36,35 +35,27 @@ def test_targets_truth(self):
with open(configfile) as fx:
params = yaml.load(fx)

#- Trim for faster initial testing
px = dict()
px['targets'] = dict()
px['targets']['ELG'] = params['targets']['ELG']
px['contaminants'] = dict()
px['contaminants']['targets'] = dict()
px['contaminants']['targets']['ELG'] = params['contaminants']['targets']['ELG']
params = px

for targettype in params['targets'].keys():
mockfile = params['targets'][targettype]['mockfile'].format(**os.environ)
self.assertTrue(os.path.isfile(mockfile), 'Missing {}'.format(mockfile))
self.assertTrue(os.path.exists(mockfile), 'Missing {}'.format(mockfile))

#- Test without spectra
targets_truth(px, healpixels=[99737,], nside=256, output_dir=self.outdir, no_spectra=True)
targets_truth(params, healpixels=[99737,], nside=256, output_dir=self.outdir, no_spectra=True)
targetfile = self.outdir + '/997/99737/targets-256-99737.fits'
truthfile = self.outdir + '/997/99737/truth-256-99737.fits'
self.assertTrue(os.path.exists(targetfile))
self.assertTrue(os.path.exists(truthfile))

with fitsio.FITS(truthfile) as fx:
self.assertTrue('TRUTH' in fx)
self.assertTrue('WAVE' not in fx)
self.assertTrue('FLUX' not in fx)
#- WAVE is there, and FLUX is there but with strange shape (n,0)
# self.assertTrue('WAVE' not in fx)
# self.assertTrue('FLUX' not in fx)

#- Test with spectra
shutil.rmtree(self.outdir+'/997')

targets_truth(px, healpixels=[99737,], nside=256, output_dir=self.outdir, no_spectra=False)
targets_truth(params, healpixels=[99737,], nside=256, output_dir=self.outdir, no_spectra=False)
self.assertTrue(os.path.exists(targetfile))
self.assertTrue(os.path.exists(truthfile))

Expand Down

0 comments on commit 66d4a71

Please sign in to comment.