summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
authorTiago Natel <t.nateldemoura@f5.com>2019-11-26 16:00:11 +0000
committerTiago Natel <t.nateldemoura@f5.com>2019-11-26 16:00:11 +0000
commit224787bbaccfc2d065cbc6fb507820fe8d30cf61 (patch)
tree632952c7c2891d6e30699fd6b5a400c6efe11c14 /test/unit
parent01103c50055abef3640cef57d820567931bb3518 (diff)
downloadunit-224787bbaccfc2d065cbc6fb507820fe8d30cf61.tar.gz
unit-224787bbaccfc2d065cbc6fb507820fe8d30cf61.tar.bz2
Tests: added getjson() helper.
Diffstat (limited to '')
-rw-r--r--test/unit/feature/isolation.py3
-rw-r--r--test/unit/http.py20
2 files changed, 20 insertions, 3 deletions
diff --git a/test/unit/feature/isolation.py b/test/unit/feature/isolation.py
index 6a429fb1..3f474993 100644
--- a/test/unit/feature/isolation.py
+++ b/test/unit/feature/isolation.py
@@ -82,6 +82,3 @@ class TestFeatureIsolation(TestApplicationProto):
data = int(os.readlink(nspath)[len(nstype) + 2 : -1])
return data
-
- def parsejson(self, data):
- return json.loads(data)
diff --git a/test/unit/http.py b/test/unit/http.py
index d59c7b56..839e91a2 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -122,6 +122,9 @@ class TestHTTP(TestUnit):
encoding
)
+ if 'json' in kwargs:
+ resp = self._parse_json(resp)
+
if 'start' not in kwargs:
sock.close()
return resp
@@ -230,6 +233,23 @@ class TestHTTP(TestUnit):
return body
+ def _parse_json(self, resp):
+ headers = resp['headers']
+
+ self.assertIn('Content-Type', headers, 'Content-Type header set')
+ self.assertEqual(
+ headers['Content-Type'],
+ 'application/json',
+ 'Content-Type header is application/json',
+ )
+
+ resp['body'] = json.loads(resp['body'])
+
+ return resp
+
+ def getjson(self, **kwargs):
+ return self.get(json=True, **kwargs)
+
def waitforsocket(self, port):
ret = False