def test_delete_on_delete(self): self.assertEqual( http_call( "DELETE", "http://localhost/app/++services++json/delete").getBody(), b"DELETED !!", )
def test_get_on_service(self): self.assertEqual( json.loads( http_call( "GET", "http://localhost/app/++services++json/dump").getBody()), {"SomeKey": "SomeValue"}, )
def test_with_cors(self): response = http_call("OPTIONS", "http://localhost/app") self.assertEqual( response.getHeaders(), [ ("Access-Control-Allow-Methods", "PUT"), ("Access-Control-Allow-Origin", "http://localhost:8080"), ("Content-Length", "0"), ], )
def not_existing_post(self): with self.assertRaces(NotImplementedError): http_call('POST', 'http://locahost/app')
def test_existing_get(self): self.assertEqual( http_call("GET", "http://localhost/app").getBody(), b"HI FROM GET")
def test_without_cors(self): import zope.security.interfaces with self.assertRaises(zope.security.interfaces.Unauthorized): http_call("OPTIONS", "http://localhost/no_cors_app")
def test_with_cors(self): response = http_call("GET", "http://localhost/authapp", Authorization="Bearer blablub") print(response.getBody())
def test_unauth(self): import zope.security.interfaces with self.assertRaises(zope.security.interfaces.Unauthorized): http_call("OPTIONS", "http://localhost/app/++services++json/dump")
def test_unknown_service(self): with self.assertRaises(LookupError): http_call("OPTIONS", "http://localhost/app/++services++test")
def test_not_implemnted_service(self): with self.assertRaises(NotImplementedError): http_call("OPTIONS", "http://localhost/app/++services++")