示例#1
0
文件: test_doc.py 项目: ocni-dtu/maas
 def test_describe_resource_authenticated_resource(self):
     # When the resource requires authentication, but has no fallback
     # anonymous handler, the first is described. The resource name comes
     # from this handler.
     resource = OperationsResource(ExampleHandler, sentinel.auth)
     expected = {
         "anon": None,
         "auth": describe_handler(ExampleHandler),
         "name": "ExampleHandler",
     }
     self.assertEqual(expected, describe_resource(resource))
示例#2
0
文件: test_doc.py 项目: ocni-dtu/maas
 def test_describe_resource_authenticated_resource_with_fallback(self):
     # When the resource requires authentication, but has a fallback
     # anonymous handler, both are described. The resource name is taken
     # from the authenticated handler.
     self.patch(ExampleHandler, "anonymous", ExampleFallbackHandler)
     resource = OperationsResource(ExampleHandler, sentinel.auth)
     expected = {
         "anon": describe_handler(ExampleFallbackHandler),
         "auth": describe_handler(ExampleHandler),
         "name": "ExampleHandler",
     }
     self.assertEqual(expected, describe_resource(resource))
示例#3
0
文件: test_doc.py 项目: ocni-dtu/maas
 def test_describe_resource_anonymous_resource(self):
     # When the resource does not require authentication, any configured
     # fallback is ignored, and only the resource's handler is described.
     # The resource name comes from this handler.
     self.patch(ExampleHandler, "anonymous", ExampleFallbackHandler)
     resource = OperationsResource(ExampleHandler)
     expected = {
         "anon": describe_handler(ExampleHandler),
         "auth": None,
         "name": "ExampleHandler",
     }
     self.assertEqual(expected, describe_resource(resource))