示例#1
0
    def testexported_as_is_optional(self):
        # If exported_as is not passed then we expect the function to be
        # exported in the API using the actual function name itself.

        def exported_function():
            pass

        decorate = operation(idempotent=True)
        decorated = decorate(exported_function)
        self.assertEqual("exported_function", decorated.export[1])
示例#2
0
 def test_non_idempotent_uses_POST(self):
     # If a function is declared as not idempotent the export signature
     # includes the HTTP POST method.
     func = lambda: None
     self.assertEqual(("POST", func.__name__),
                      operation(idempotent=False)(func).export)
示例#3
0
 def test_idempotent_uses_GET(self):
     # If a function is declared as idempotent the export signature
     # includes the HTTP GET method.
     func = lambda: None
     self.assertEqual(("GET", func.__name__),
                      operation(idempotent=True)(func).export)
示例#4
0
 def test_can_passexported_as(self):
     # Test that passing the optional "exported_as" works as expected.
     randomexported_name = factory.make_name("exportedas", sep='')
     decorate = operation(idempotent=False, exported_as=randomexported_name)
     decorated = decorate(lambda: None)
     self.assertEqual(randomexported_name, decorated.export[1])
示例#5
0
 def test_valid_decoration(self):
     value = "value" + factory.getRandomString()
     decorate = operation(idempotent=False)
     decorated = decorate(lambda: value)
     self.assertEqual(value, decorated())