Skip to content

Commit

Permalink
fix batch tests
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 18, 2023
1 parent 8c2eb30 commit ad42cdd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions py/specprodDB/test/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_get_options(self):
"""
options = get_options()
self.assertTrue(options.csh)
self.assertEqual(options.hostname, 'specprod-db.desi.lbl.gov')
self.assertEqual(options.root, '/global/cfs/cdirs/desi')

@patch('sys.argv', ['prepare_batch_specprod_db', '--csh', '--schema', 'fuji', 'foo@example.com', '/global/cfs/cdirs/desi'])
def test_prepare_template_csh(self):
Expand All @@ -42,14 +42,15 @@ def test_prepare_template_csh(self):
scripts = prepare_template(options)
self.assertIn('load_specprod_db_fuji_exposures.csh', scripts)

@patch('sys.argv', ['prepare_batch_specprod_db', '--schema', 'fuji', 'foo@example.com', '/global/cfs/cdirs/desi'])
@patch('sys.argv', ['prepare_batch_specprod_db', '--swap', '--schema', 'fuji', 'foo@example.com', '/global/cfs/cdirs/desi'])
def test_prepare_template_bash(self):
"""Test conversion of options to scripts with bash.
"""
with patch.dict('os.environ', {'DESI_ROOT': '/global/cfs/cdirs/desi', 'DESI_TARGET': '/global/cfs/cdirs/desi/target'}):
options = get_options()
scripts = prepare_template(options)
self.assertIn('load_specprod_db_fuji_exposures.sh', scripts)
self.assertIn('module swap', scripts['load_specprod_db_fuji_exposures.sh'])

@patch('sys.argv', ['prepare_batch_specprod_db', '--qos', 'bigmem', '--constraint', 'haswell', '--schema', 'fuji', 'foo@example.com', '/global/cfs/cdirs/desi'])
def test_prepare_template_bash_qos(self):
Expand All @@ -70,7 +71,6 @@ def test_prepare_template_bash_qos(self):
export DESI_ROOT=/global/cfs/cdirs/desi
export SPECPROD=fuji
srun --ntasks=1 load_specprod_db --overwrite \\
--hostname specprod-db.desi.lbl.gov --username desi_admin \\
--load exposures --schema ${SPECPROD} ${DESI_ROOT}
"""
photometry = """#!/bin/bash
Expand All @@ -88,7 +88,6 @@ def test_prepare_template_bash_qos(self):
export DESI_ROOT=/global/cfs/cdirs/desi
export SPECPROD=fuji
srun --ntasks=1 load_specprod_db \\
--hostname specprod-db.desi.lbl.gov --username desi_admin \\
--load photometry --schema ${SPECPROD} ${DESI_ROOT}
"""
with patch('os.environ', {'HOME': '/home/test'}):
Expand Down

0 comments on commit ad42cdd

Please sign in to comment.