Beispiel #1
0
    def test_resolve_parameters_multiple_outputs(self):
        def get_output(stack, param):
            d = {"a": "Apple", "c": "Carrot"}
            return d[param]

        self.bp.parameters = {
            "a": {
                "type": "String",
                "description": "A"},
            "b": {
                "type": "String",
                "description": "B"
                }}
        params = {"a": "other-stack::a,other-stack::c", "b": "Banana"}
        self.prov.get_output.side_effect = get_output
        p = resolve_parameters(params, self.bp, self.ctx, self.prov)
        self.assertEqual(self.prov.get_output.call_count, 2)
        self.assertEqual(p["a"], "Apple,Carrot")
        self.assertEqual(p["b"], "Banana")

        # Test multi-output with spaces
        params = {"a": "other-stack::a, other-stack::c", "b": "Banana"}
        self.prov.get_output.side_effect = get_output
        p = resolve_parameters(params, self.bp, self.ctx, self.prov)
        self.assertEqual(self.prov.get_output.call_count, 4)
        self.assertEqual(p["a"], "Apple,Carrot")
        self.assertEqual(p["b"], "Banana")
Beispiel #2
0
    def test_resolve_parameters_multiple_outputs(self):
        def get_output(stack, param):
            d = {"a": "Apple", "c": "Carrot"}
            return d[param]

        self.bp.parameters = {
            "a": {
                "type": "String",
                "description": "A"
            },
            "b": {
                "type": "String",
                "description": "B"
            }
        }
        params = {"a": "other-stack::a,other-stack::c", "b": "Banana"}
        self.prov.get_output.side_effect = get_output
        p = resolve_parameters(params, self.bp, self.ctx, self.prov)
        self.assertEqual(self.prov.get_output.call_count, 2)
        self.assertEqual(p["a"], "Apple,Carrot")
        self.assertEqual(p["b"], "Banana")

        # Test multi-output with spaces
        params = {"a": "other-stack::a, other-stack::c", "b": "Banana"}
        self.prov.get_output.side_effect = get_output
        p = resolve_parameters(params, self.bp, self.ctx, self.prov)
        self.assertEqual(self.prov.get_output.call_count, 4)
        self.assertEqual(p["a"], "Apple,Carrot")
        self.assertEqual(p["b"], "Banana")
Beispiel #3
0
 def test_resolve_parameters_none_conversion(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": None, "c": "Carrot"}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertNotIn("a", p)
Beispiel #4
0
 def test_resolve_parameters_none_conversion(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": None, "c": "Carrot"}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertNotIn("a", p)
Beispiel #5
0
    def test_resolve_parameters_output_does_not_exist(self):
        def get_output(stack, param):
            d = {"c": "Carrot"}
            return d[param]

        self.bp.parameters = {
            "a": {
                "type": "String",
                "description": "A"
            },
        }
        params = {"a": "other-stack::a"}
        self.prov.get_output.side_effect = get_output
        with self.assertRaises(exceptions.OutputDoesNotExist) as cm:
            resolve_parameters(params, self.bp, self.ctx, self.prov)

        exc = cm.exception
        self.assertEqual(exc.stack_name, "test-other-stack")
        # Not sure this is actually what we want - should probably change it
        # so the output is just the output name, not the stack name + the
        # output name
        self.assertEqual(exc.output, "other-stack::a")
Beispiel #6
0
 def test_resolve_parameters_booleans(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"},
     }
     params = {"a": True, "b": False}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertEquals("true", p["a"])
     self.assertEquals("false", p["b"])
Beispiel #7
0
    def test_resolve_parameters_output_does_not_exist(self):
        def get_output(stack, param):
            d = {'c': 'Carrot'}
            return d[param]

        self.bp.parameters = {
            "a": {
                "type": "String",
                "description": "A"
            },
        }
        params = {"a": "other-stack::a"}
        self.prov.get_output.side_effect = get_output
        with self.assertRaises(exceptions.OutputDoesNotExist) as cm:
            resolve_parameters(params, self.bp, self.ctx, self.prov)

        exc = cm.exception
        self.assertEqual(exc.stack_name, "test-other-stack")
        # Not sure this is actually what we want - should probably change it
        # so the output is just the output name, not the stack name + the
        # output name
        self.assertEqual(exc.output, "other-stack::a")
Beispiel #8
0
 def test_resolve_parameters_unused_parameter(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": "Apple", "c": "Carrot"}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertNotIn("c", p)
     self.assertIn("a", p)
Beispiel #9
0
 def test_resolve_parameters_booleans(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"},
     }
     params = {"a": True, "b": False}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertEquals("true", p["a"])
     self.assertEquals("false", p["b"])
Beispiel #10
0
 def test_resolve_parameters_unused_parameter(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": "Apple", "c": "Carrot"}
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     self.assertNotIn("c", p)
     self.assertIn("a", p)
Beispiel #11
0
 def test_resolve_parameters_resolve_outputs(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": "other-stack::a", "b": "Banana"}
     self.prov.get_output.return_value = "Apple"
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     kall = self.prov.get_output.call_args
     args, kwargs = kall
     self.assertTrue(args[0], "test-other-stack")
     self.assertTrue(args[1], "a")
     self.assertEqual(p["a"], "Apple")
     self.assertEqual(p["b"], "Banana")
Beispiel #12
0
 def test_resolve_parameters_resolve_outputs(self):
     self.bp.parameters = {
         "a": {
             "type": "String",
             "description": "A"},
         "b": {
             "type": "String",
             "description": "B"
             }}
     params = {"a": "other-stack::a", "b": "Banana"}
     self.prov.get_output.return_value = "Apple"
     p = resolve_parameters(params, self.bp, self.ctx, self.prov)
     kall = self.prov.get_output.call_args
     args, kwargs = kall
     self.assertTrue(args[0], "test-other-stack")
     self.assertTrue(args[1], "a")
     self.assertEqual(p["a"], "Apple")
     self.assertEqual(p["b"], "Banana")