Be robust in what you accept, which might be a JSON object w/o an outer wrapper 'data' object.
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index a8da2b6..2bf0302 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -140,5 +140,23 @@
content = model.response(resp, content)
self.assertEqual(content, 'is good')
+ def test_good_response_wo_data(self):
+ model = JsonModel()
+ resp = httplib2.Response({'status': '200'})
+ resp.reason = 'OK'
+ content = '{"foo": "is good"}'
+
+ content = model.response(resp, content)
+ self.assertEqual(content, {'foo': 'is good'})
+
+ def test_good_response_wo_data_str(self):
+ model = JsonModel()
+ resp = httplib2.Response({'status': '200'})
+ resp.reason = 'OK'
+ content = '"data goes here"'
+
+ content = model.response(resp, content)
+ self.assertEqual(content, 'data goes here')
+
if __name__ == '__main__':
unittest.main()