Skip to content

Commit

Permalink
Merge pull request #192 from MelbourneGenomics/dev
Browse files Browse the repository at this point in the history
Fix manage batch unit tests
  • Loading branch information
multimeric authored Nov 2, 2016
2 parents 423bafc + 0476905 commit 3b592c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pipeline/scripts/manage_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run_command(cmd, log):
execute a command on the shell
'''
write_log(log, "executing: {0}...".format(cmd))
subprocess.check_call(cmd, shell=True, executable='bash')
subprocess.check_call(cmd, shell=True, executable='bash', stdout=log, stderr=log)
write_log(log, "executing: {0}: done".format(cmd))


Expand Down
10 changes: 7 additions & 3 deletions pipeline/tests/manage_batch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
def suppress_stdout():
with open(os.devnull, "w") as devnull:
old_stdout = sys.stdout
old_stderr = sys.stderr
sys.stdout = devnull
sys.stderr = devnull
try:
yield
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr

class ManageBatchTest(unittest.TestCase):
test_batch_name = 'test'
Expand All @@ -31,7 +34,8 @@ class ManageBatchTest(unittest.TestCase):
sample_metadata = os.path.join(test_batch_dir, 'samples.txt')

def create_test_batch(self):
add_batch(self.test_batch_name, 'ALL', None, self.test_data_files, None, log=sys.stdout)
with open(os.devnull, "w") as devnull:
add_batch(self.test_batch_name, 'ALL', None, self.test_data_files, None, log=devnull)

def delete_test_batch(self):
batch_dir = os.path.join(BASE, 'batches', self.test_batch_name)
Expand Down Expand Up @@ -76,8 +80,8 @@ def test_show_batch(self):
def test_add_sample(self):
self.create_test_batch()
initial_size = os.stat(self.sample_metadata).st_size
with suppress_stdout():
add_sample(self.test_batch_name, 'ALL', self.test_data_files, sys.stdout)
with suppress_stdout(), open(os.devnull, "w") as devnull:
add_sample(self.test_batch_name, 'ALL', self.test_data_files, log=devnull)
final_size = os.stat(self.sample_metadata).st_size
self.delete_test_batch()
assert(final_size > initial_size)

0 comments on commit 3b592c3

Please sign in to comment.