def test_authorization_static_token(self): api = APIManager(None, None, self.server.path, compression_enabled=False, backoff_config=None, token_override="static_token") r = api.get("/api/v3/api_manager") self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.post("/api/v3/api_manager", {}) self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.put("/api/v3/api_manager", {}) self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.delete("/api/v3/api_manager") self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token')
def test_compression_post(self): api = APIManager("CLIENT_ID", "CLIENT_SECRET", self.server.path, True) content = {"some_property": "some_value", "some_boolean": True} r = api.post("compression_enabled", content) self.assertIn('Content-Encoding', r.request.headers) self.assertEquals('gzip', r.request.headers['Content-Encoding']) self.assertIn('Content-Encoding', r.headers) self.assertEquals('gzip', r.headers['Content-Encoding']) # content already decompressed by python-requests self.assertEquals(content, r.json())