Skip to content

Commit

Permalink
Fixing sample template GUI (#2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
josenavas authored and antgonza committed Dec 14, 2016
1 parent 490045f commit 59ba775
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
41 changes: 24 additions & 17 deletions qiita_pet/handlers/api_proxy/sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,31 @@ def get_sample_template_processing_status(st_id):
job_info = loads(job_info)
job_id = job_info['job_id']
if job_id:
redis_info = loads(r_client.get(job_id))
processing = redis_info['status_msg'] == 'Running'
if processing:
alert_type = 'info'
alert_msg = 'This sample template is currently being processed'
elif redis_info['status_msg'] == 'Success':
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace('\n',
'</br>')
payload = {'job_id': None,
'status': alert_type,
'message': alert_msg}
r_client.set(SAMPLE_TEMPLATE_KEY_FORMAT % st_id,
dumps(payload))
redis_info = r_client.get(job_id)
if redis_info:
redis_info = loads(redis_info)
processing = redis_info['status_msg'] == 'Running'
if processing:
alert_type = 'info'
alert_msg = ('This sample template is currently being '
'processed')
elif redis_info['status_msg'] == 'Success':
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace(
'\n', '</br>')
payload = {'job_id': None,
'status': alert_type,
'message': alert_msg}
r_client.set(SAMPLE_TEMPLATE_KEY_FORMAT % st_id,
dumps(payload))
else:
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace(
'\n', '</br>')
else:
alert_type = redis_info['return']['status']
alert_msg = redis_info['return']['message'].replace('\n',
'</br>')
processing = False
alert_type = ''
alert_msg = ''
else:
processing = False
alert_type = job_info['status']
Expand Down
7 changes: 7 additions & 0 deletions qiita_pet/handlers/api_proxy/tests/test_sample_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ def test_get_sample_template_processing_status(self):
self.assertEqual(obs_at, "error")
self.assertEqual(obs_am, "Some</br>error")

# With job expired
r_client.set(key, dumps({'job_id': "non_existent_job"}))
obs_proc, obs_at, obs_am = get_sample_template_processing_status(1)
self.assertFalse(obs_proc)
self.assertEqual(obs_at, "")
self.assertEqual(obs_am, "")

def test_sample_template_summary_get_req(self):
obs = sample_template_summary_get_req(1, 'test@foo.bar')
exp = {
Expand Down

0 comments on commit 59ba775

Please sign in to comment.