示例#1
0
 def test_globals(self):
     template = Template()
     globals = Globals()
     with self.assertRaises(ValueError):
         template.set_globals(globals)
     transform = "AWS::Serverless-2016-10-31"
     template.set_transform(transform)
     template.set_globals(globals)
     self.assertEqual(template.globals, globals)
     with self.assertRaises(ValueError):
         template.set_transform("other_transform")
示例#2
0
    def test_globals(self):
        t = Template()
        t.set_transform(SERVERLESS_TRANSFORM)
        t.set_globals(
            Globals(
                Function=FunctionGlobals(),
                Api=ApiGlobals(),
                HttpApi=HttpApiGlobals(),
                SimpleTable=SimpleTableGlobals(),
            ))
        t.to_json()

        with self.assertRaises(ValueError):
            _ = Globals(Unexpected="blah")
        with self.assertRaises(ValueError):
            _ = Globals(Function="not FunctionGlobals")