Skip to content

Commit 333ef56

Browse files
seg1129Tyler Rivera
authored andcommitted
Dev (#28)
* Update driver.py (#26) * 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 * Update driver.py (#26) * 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
1 parent 619bc8b commit 333ef56

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
1.0.4
3+
* fixing issue8 - driver execption: adding additional nautilius issue mappings
4+
* added additional nautlis mappings - 'SER': 'Serum'
5+
26
1.0.3
37
-----
48
* Add additional Nautilus mappings

ehb_datasources/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
__version_info__ = {
22
'major': 1,
33
'minor': 0,
4-
'micro': 2,
4+
'micro': 4,
55
'releaselevel': 'final',
6-
'serial': 23
6+
'serial': 25
77
}
88

99

ehb_datasources/drivers/nautilus/driver.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ class ehbDriver(Driver, RequestHandler):
2626
NAU_ERROR_MAP = {
2727
'0': 'UNKNOWN ERROR',
2828
'1': 'Unable to login into LIMS',
29-
'8': 'Form data is not valid'
29+
'2': 'Username not provided',
30+
'3': 'Password not provided',
31+
'4': 'Request type not provided',
32+
'5': 'Request body not provided',
33+
'6': 'Malformed Request',
34+
'7': 'Unsupported request type',
35+
'8': 'Form data is not valid',
36+
'100': 'NAU socket service not found',
37+
'101': 'NAU invalid authorization header'
38+
3039
}
3140

3241
def __init__(self, url, user, password, secure):
@@ -175,6 +184,7 @@ def format_aliquots(self, sample_data):
175184
'CELN': 'Cell Line',
176185
'CELLFRZ': 'Cell Freeze',
177186
'SAL': 'Saliva',
187+
'SER': 'Serum',
178188
'SLD': 'Slide',
179189
'LYS': 'Lysate',
180190
'XEN': 'Xenograft',

ehb_datasources/tests/unit_tests/test_nautilus_driver.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import pytest
2+
import json
3+
24

35
from ehb_datasources.drivers.nautilus.driver import ehbDriver
46
from ehb_datasources.drivers.exceptions import RecordCreationError, \
@@ -235,3 +237,40 @@ def test_process_new_record_form_no_sdg(driver, mocker):
235237
driver.process_new_record_form(request, 'TESTPREFIX', validator_func)
236238

237239
assert excinfo.typename == 'RecordCreationError'
240+
241+
242+
# creating parameratized unit tests for testing error message received from lims
243+
examples = (('expected_error_message', 'status_error_num', 'test_comment'), [
244+
# keeping comments blank because 'error message' in this case is sufficient.
245+
# Keeping here for best practices in the future.
246+
('Username not provided', "2", ''),
247+
('Password not provided', "3", ''),
248+
('Request type not provided', "4", ''),
249+
('Request body not provided', "5", ''),
250+
('Malformed Request', "6", ''),
251+
('Unsupported request type', "7", ''),
252+
('Form data is not valid', "8", ''),
253+
('NAU socket service not found', "100", ''),
254+
('NAU invalid authorization header', "101", '')
255+
])
256+
257+
258+
@pytest.mark.parametrize(*examples)
259+
def test_process_new_record_lims(driver, mocker, expected_error_message, status_error_num, test_comment):
260+
request = mocker.MagicMock(
261+
method='POST',
262+
_post={'SDG_NAME': '7316-118', 'csrfmiddlewaretoken': 'foo', 'label_id': '1'}
263+
)
264+
payload = [
265+
{
266+
"status": status_error_num,
267+
}
268+
]
269+
# using .encode() because fn in driver is expecting bytes
270+
driver.update = mocker.MagicMock(return_value=json.dumps(payload).encode())
271+
validator_func = mocker.MagicMock(return_value=0)
272+
with pytest.raises(RecordCreationError) as excinfo:
273+
driver.process_new_record_form(request, 'TESTPREFIX', validator_func)
274+
275+
assert excinfo.typename == 'RecordCreationError'
276+
assert excinfo.value.cause == expected_error_message

0 commit comments

Comments
 (0)