Exemple #1
0
    def test_template_extraction(self):
        values = {"ValueToSub1": "test1234"}
        fns = cfn_lambda_extractor.extract_functions(self.data, values)

        efn1 = open(self.testdata_dir + "expected_output_fn1.py")
        expected_output_fn1 = efn1.read()
        efn1.close()

        efn2 = open(self.testdata_dir + "expected_output_fn2.py")
        expected_output_fn2 = efn2.read()
        efn2.close()

        self.assertEqual("".join(fns["0"]), expected_output_fn1.rstrip('\n'))
Exemple #2
0
    def test(self):
        d = os.path.dirname(os.path.realpath(__file__))
        testdata_dir = d + "/testdata/"
        test_template = testdata_dir + "test_template.yaml"
        data = cfn_lambda_extractor.load_input_file(test_template)
        values = {"ValueToSub1": "'test4321'"}
        fns = cfn_lambda_extractor.extract_functions(data, values)

        efn1 = open(testdata_dir + "expected_output_fn1.py")
        expected_output_fn1 = efn1.read()
        efn1.close()

        efn2 = open(testdata_dir + "expected_output_fn2.py")
        expected_output_fn2 = efn2.read()
        efn2.close()

        self.assertEqual("".join(fns["1"]), expected_output_fn2)
        self.assertEqual("".join(fns["0"]), expected_output_fn1)
Exemple #3
0
 def test_no_resources(self):
     with self.assertRaises(Exception) as e:
         cfn_lambda_extractor.extract_functions("", {})
     self.assertEqual(str(e.exception), "No Resources in template.")
Exemple #4
0
 def test_value_not_provided(self):
     with self.assertRaises(Exception) as e:
         cfn_lambda_extractor.extract_functions(self.data, {})
     err = str(e.exception)
     self.assertTrue(re.match("Value 'ValueToSub.' not provided.", err))
 def test_value_not_provided(self):
     with self.assertRaises(Exception) as e:
         cfn_lambda_extractor.extract_functions(self.data, {})
     self.assertEqual(str(e.exception), "Value 'ValueToSub1' not provided.")