Skip to content

Commit

Permalink
fix tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
squirrelo committed Jul 2, 2014
1 parent d0bb7fb commit 4a6edda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions qiita_db/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ def options(self, opts):
opts: dict
The options for the command in format {option: value}
"""
conn_handler = SQLConnectionHandler()
# make sure job is editable
self._lock_job()
self._lock_job(conn_handler)

conn_handler = SQLConnectionHandler()
# JSON the options dictionary
opts_json = dumps(opts, sort_keys=True, separators=(',', ':'))
# Add the options to the job
Expand Down
22 changes: 13 additions & 9 deletions qiita_db/test/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ def test_get_commands(self):
def test_create(self):
"""Makes sure creation works as expected"""
# make first job
new = Job.create("18S", "Alpha Rarefaction",
self.options, Analysis(1))
new = Job.create("18S", "Alpha Rarefaction", Analysis(1))
self.assertEqual(new.id, 4)
# make sure job inserted correctly
obs = self.conn_handler.execute_fetchall("SELECT * FROM qiita.job "
"WHERE job_id = 4")
exp = [[4, 2, 1, 3, '{"option1":false,"option2":25,"option3":"NEW"}',
None]]
exp = [[4, 2, 1, 3, None, None]]
self.assertEqual(obs, exp)
# make sure job added to analysis correctly
obs = self.conn_handler.execute_fetchall("SELECT * FROM "
Expand All @@ -91,14 +89,12 @@ def test_create(self):
self.assertEqual(obs, exp)

# make second job with diff datatype and command to test column insert
new = Job.create("16S", "Beta Diversity",
self.options, Analysis(1))
new = Job.create("16S", "Beta Diversity", Analysis(1))
self.assertEqual(new.id, 5)
# make sure job inserted correctly
obs = self.conn_handler.execute_fetchall("SELECT * FROM qiita.job "
"WHERE job_id = 5")
exp = [[5, 1, 1, 2, '{"option1":false,"option2":25,"option3":"NEW"}',
None]]
exp = [[5, 1, 1, 2, None, None]]
self.assertEqual(obs, exp)
# make sure job added to analysis correctly
obs = self.conn_handler.execute_fetchall("SELECT * FROM "
Expand Down Expand Up @@ -130,11 +126,19 @@ def test_retrieve_options(self):
'1_summarize_taxa_through_plots.py'
'_output_dir')})

def test_set_options(self):
new = Job.create("18S", "Alpha Rarefaction", Analysis(1))
new.options = self.options
self.options['--output_dir'] = join(get_db_files_base_dir(),
'job/4_alpha_rarefaction.'
'py_output_dir')
self.assertEqual(new.options, self.options)

def test_retrieve_results(self):
self.assertEqual(self.job.results, [join("job", "1_job_result.txt")])

def test_retrieve_results_empty(self):
new = Job.create("18S", "Beta Diversity", self.options, Analysis(1))
new = Job.create("18S", "Beta Diversity", Analysis(1))
self.assertEqual(new.results, [])

def test_retrieve_results_dir(self):
Expand Down

0 comments on commit 4a6edda

Please sign in to comment.