Skip to content

Commit

Permalink
issue#29_nautilus_feedback_to_ui (#31)
Browse files Browse the repository at this point in the history
* adding lims error message to driver and unit tests for changes made (#27)

* adding lims error message to driver and unit tests for changes made

* adding SER : Serum, back into driver

* updating version

* adding lims error message to driver and unit tests for changes made (#27)

* adding lims error message to driver and unit tests for changes made

* adding SER : Serum, back into driver

* adding error from Nautilus API to Html

* adding error message when there is an issue rendering information to the bioRepo UI from LIMS system

* adding info to changelog

* update unit tests
  • Loading branch information
seg1129 authored Jun 26, 2017
1 parent 333ef56 commit 2a5c931
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
1.0.4
* fixing issue8 - driver execption: adding additional nautilius issue mappings
* added additional nautlis mappings - 'SER': 'Serum'
* added nautlis error messages to biorepository UI

1.0.3
-----
Expand Down
43 changes: 29 additions & 14 deletions ehb_datasources/drivers/nautilus/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import logging
import os
import codecs
from collections import OrderedDict
import urllib.request, urllib.parse, urllib.error

Expand All @@ -24,18 +25,17 @@ class ehbDriver(Driver, RequestHandler):
NAU_REC_EXT_REF = 'ext-ref'
VALID_NAU_ELEM_IDENTIFIERS = [NAU_REC_ID, NAU_REC_NAME, NAU_REC_EXT_REF]
NAU_ERROR_MAP = {
'0': 'UNKNOWN ERROR',
'1': 'Unable to login into LIMS',
'2': 'Username not provided',
'3': 'Password not provided',
'4': 'Request type not provided',
'5': 'Request body not provided',
'6': 'Malformed Request',
'7': 'Unsupported request type',
'8': 'Form data is not valid',
'100': 'NAU socket service not found',
'101': 'NAU invalid authorization header'

'0': 'UNKNOWN ERROR.',
'1': 'Unable to communicate with Laboratory System because of expired or incorrect credentials.',
'2': 'Username not provided.',
'3': 'Password not provided.',
'4': 'Request type not provided.',
'5': 'Request body not provided.',
'6': 'Malformed Request.',
'7': 'Unsupported request type.',
'8': 'Form data is not valid.',
'100': 'NAU socket service not found.',
'101': 'NAU invalid authorization header.'
}

def __init__(self, url, user, password, secure):
Expand Down Expand Up @@ -136,8 +136,17 @@ def get_sample_data(self, *args, **kwargs):
try:
return json.loads(response)[0]
except KeyError:
log.error('Error retrieving sample data')
return {"error": "Unable to retrieve sample data"}
try: # grab error number and process error
responseDict = json.loads(response)
status = responseDict['error']
errorMsg = self.NAU_ERROR_MAP.get(status, 'UNKNOWN ERROR')
log.error(errorMsg)
return {"error": errorMsg}
except TypeError:
pass
except KeyError:
log.error('Error retrieving sample data')
return {"error": "Unable to retrieve sample data"}

def extract_aliquots(self, sample_data):
aliquots = []
Expand Down Expand Up @@ -278,6 +287,12 @@ def subRecordSelectionForm(self, form_url='', record_id='', *args,
c = {
'aliquots': aliquots,
}
try: # grab error message
errorMsg = (sdg['error'])
c = {'error': errorMsg}
log.error(errorMsg)
except:
pass
html = t.render(c)
return html

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
<td>{{alq.label}}{% if alq.is_received %}<small class="text-muted"> <small style="font-size:1em"> -- Collected On: {{alq.U_COLLECT_DATE_TIME}} -- Received On: {{alq.U_RECEIVED_DATE_TIME}}</small>{% endif %}<span class="label label-primary pull-right muted">{{alq.NAME}}</span></td><td align="center">{{alq.STATUS|safe}}</td>
</tr>
{% endfor %}

</tbody>
</table>

{% if error %}
<div class="alert alert-danger" role="alert">
<strong>Warning!</strong> {{error}} Please contact the data coordinating center or <a href="mailto:[email protected]"> [email protected] </a> .
</div>
{% endif %}
<br>
<br>
</div>
18 changes: 9 additions & 9 deletions ehb_datasources/tests/unit_tests/test_nautilus_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ def test_process_new_record_form_no_sdg(driver, mocker):
examples = (('expected_error_message', 'status_error_num', 'test_comment'), [
# keeping comments blank because 'error message' in this case is sufficient.
# Keeping here for best practices in the future.
('Username not provided', "2", ''),
('Password not provided', "3", ''),
('Request type not provided', "4", ''),
('Request body not provided', "5", ''),
('Malformed Request', "6", ''),
('Unsupported request type', "7", ''),
('Form data is not valid', "8", ''),
('NAU socket service not found', "100", ''),
('NAU invalid authorization header', "101", '')
('Username not provided.', "2", ''),
('Password not provided.', "3", ''),
('Request type not provided.', "4", ''),
('Request body not provided.', "5", ''),
('Malformed Request.', "6", ''),
('Unsupported request type.', "7", ''),
('Form data is not valid.', "8", ''),
('NAU socket service not found.', "100", ''),
('NAU invalid authorization header.', "101", '')
])


Expand Down

0 comments on commit 2a5c931

Please sign in to comment.