diff --git a/test/flowsheets.data.not.saved.yaml b/test/flowsheets.data.not.saved.yaml new file mode 100644 index 0000000..812756c --- /dev/null +++ b/test/flowsheets.data.not.saved.yaml @@ -0,0 +1,55 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + User-Agent: + - python-requests/2.27.1 + authorization: + - EPIC_AUTHORIZATION + content-type: + - application/json + cookie: + - EPIC_COOKIE + epic-client-id: + - EPIC_CLIENT_ID + epic-user-id: + - PENNSIGNALS + epic-user-idtype: + - external + method: POST + uri: https://interconnectbgprod.uphs.upenn.edu/interconnect-prd-web/api/epic/2011/clinical/patient/addflowsheetvalue/flowsheetvalue?Comment=0&ContactID=133713371&ContactIDType=CSN&FlowsheetID=0000000000&FlowsheetIDType=external&FlowsheetTemplateID=0000000000&FlowsheetTemplateIDType=external&InstantValueTaken=2019-09-18T17%3A19%3A23Z&PatientID=1337133713&PatientIDType=UID&UserID=PENNSIGNALS&UserIDType=external&Value=0.5 + response: + body: + string: '{"Message":"An error has occurred.","ExceptionMessage":"An error occurred while executing the command: DATA_NOT_SAVED details: There was an error filing data. Data was not saved.."}}' + headers: + Cache-Control: + - no-cache,no-store + Content-Length: + - '183' + Content-Type: + - application/json; charset=utf-8 + Date: + - Wed, 19 Jan 2022 20:14:44 GMT + Expires: + - '-1' + Pragma: + - no-cache + Server: + - Microsoft-IIS/8.5 + X-AspNet-Version: + - 4.0.30319 + X-Powered-By: + - ASP.NET + status: + code: 400 + message: 'An error occurred while executing the command: DATA_NOT_SAVED details + : There was an error filing data. Data was not saved..' +version: 1 diff --git a/test/test_flowsheets.py b/test/test_flowsheets.py index 221d5c7..ac49cb6 100644 --- a/test/test_flowsheets.py +++ b/test/test_flowsheets.py @@ -96,3 +96,34 @@ def test_invalid_empi(mock_flowsheets_service): assert result.status is False assert result.status_code == 400 assert result.name == "HTTPError" + + +@vcr.use_cassette("./test/flowsheets.data.not.saved.yaml") +def test_invalid_empi(mock_flowsheets_service): + """Test data not saved.""" + service = mock_flowsheets_service + + postgres = service.postgres + postgres.df_from_query.return_value = DataFrame( + [ + { + "as_of": service.as_of, + "csn": 133713371, + "empi": "1337133713", + "id": 0, + "run_id": 0, + "score": 0.5, + } + ] + ) + expected = ( + "An error occurred while executing the command: " + "DATA_NOT_SAVED details : There was an error " + "filing data. Data was not saved.." + ) + + for result in service.publish(): + assert result.description == expected + assert result.status is False + assert result.status_code == 400 + assert result.name == "SaveError"