| 203 | ) |
| 204 | |
| 205 | def test_bad_response(self): |
| 206 | model = JsonModel(data_wrapper=False) |
| 207 | resp = httplib2.Response({"status": "401"}) |
| 208 | resp.reason = "Unauthorized" |
| 209 | content = b'{"error": {"message": "not authorized"}}' |
| 210 | |
| 211 | try: |
| 212 | content = model.response(resp, content) |
| 213 | self.fail("Should have thrown an exception") |
| 214 | except HttpError as e: |
| 215 | self.assertTrue("not authorized" in str(e)) |
| 216 | |
| 217 | resp["content-type"] = "application/json" |
| 218 | |
| 219 | try: |
| 220 | content = model.response(resp, content) |
| 221 | self.fail("Should have thrown an exception") |
| 222 | except HttpError as e: |
| 223 | self.assertTrue("not authorized" in str(e)) |
| 224 | |
| 225 | def test_good_response(self): |
| 226 | model = JsonModel(data_wrapper=True) |