Skip to content

Commit 3b5b588

Browse files
committed
Added unit tests which checks for responseHeaders
1 parent 72ca527 commit 3b5b588

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/mock-data/response/eng-doc-entities.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,13 @@
150150
"rblJe": 29,
151151
"rexJe": 656,
152152
"rliJe": 35
153+
},
154+
"responseHeaders": {
155+
"connection": "keep-alive",
156+
"content-length": "637",
157+
"content-type": "application/json",
158+
"date": "Wed, 02 Mar 2016 23:09:51 GMT",
159+
"server": "openresty/1.7.4.1",
160+
"x-rosetteapi-request-id": "2be64f9f-6246-4366-aab3-16f635ed87a5"
153161
}
154162
}

tests/test_rosette_api.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,20 @@ def test_retry500():
166166
# Test that getting the info about the API is being called correctly
167167
@httpretty.activate
168168
def test_responseHeaders():
169+
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/entities",
170+
status=200,
171+
body=get_file_content(response_file_dir + "eng-doc-entities.json"),
172+
content_type="application/json")
173+
# need to mock /info call too because the api will call it implicitly
169174
with open(response_file_dir + "info.json", "r") as info_file:
170175
body = info_file.read()
171176
httpretty.register_uri(httpretty.GET, "https://api.rosette.com/rest/v1/info",
172177
body=body, status=200, content_type="application/json")
173-
174-
test = RosetteTest(None)
175-
result = test.api.info()
176-
assert result["buildNumber"] == "6bafb29d"
177-
assert result["name"] == "Rosette API"
178-
assert result["versionChecked"] is True
178+
httpretty.register_uri(httpretty.POST, "https://api.rosette.com/rest/v1/info",
179+
body=body, status=200, content_type="application/json")
180+
test = RosetteTest("eng-doc-entities")
181+
result = test.api.entities(test.params)
182+
assert ("responseHeaders" in result) == True
179183

180184

181185
@httpretty.activate

0 commit comments

Comments
 (0)