Skip to content

Commit

Permalink
add test for DATA_NOT_SAVED
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Becker committed Feb 9, 2022
1 parent ee1e183 commit 54467c6
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/flowsheets.data.not.saved.yaml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions test/test_flowsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 54467c6

Please sign in to comment.