示例#1
0
    def test_heat_deployed_environment_error(self):
        """
        Test salt.states.heat.deployed method
        with environment set and there is an error
        reading the environment file.
        """
        exp_ret = {
            "name": ("mystack", ),
            "comment":
            "Error parsing template Template format version not found.",
            "changes": {
                "stack_name": "mystack",
                "comment": "Create stack"
            },
            "result": False,
        }

        patch_heat = patch.dict(
            heat.__salt__,
            {
                "heat.show_stack": MagicMock(return_value={"result": False}),
                "heat.create_stack": salt.modules.heat.create_stack,
            },
        )

        patch_file = patch.dict(
            "salt.modules.heat.__salt__",
            {
                "file.get_managed":
                file_.get_managed,
                "file.manage_file":
                MagicMock(side_effect=[{
                    "result": True
                }, {
                    "result": False
                }]),
            },
        )

        patch_create = patch(
            "salt.modules.heat.create_stack",
            MagicMock(return_value={
                "result": True,
                "comment": "Created stack 'mystack'."
            }),
        )

        with patch_heat, patch_file, patch_create, self.patch_check:
            ret = heat.deployed(
                name="mystack",
                profile="openstack1",
                template=os.path.join(RUNTIME_VARS.BASE_FILES, "templates",
                                      "heat-template.yml"),
                poll=0,
                environment=os.path.join(RUNTIME_VARS.BASE_FILES, "templates",
                                         "heat-env.yml"),
            )
        assert ret == exp_ret
示例#2
0
    def test_heat_deployed(self):
        """
        Test salt.states.heat.deployed method
        """
        exp_ret = {
            "name": ("mystack", ),
            "comment": "Created stack 'mystack'.",
            "changes": {
                "stack_name": "mystack",
                "comment": "Create stack"
            },
            "result": True,
        }

        patch_heat = patch.dict(
            heat.__salt__,
            {
                "heat.show_stack": MagicMock(return_value={"result": False}),
                "heat.create_stack": salt.modules.heat.create_stack,
            },
        )

        patch_file = patch.dict(
            "salt.modules.heat.__salt__",
            {
                "file.get_managed": file_.get_managed,
                "file.manage_file": file_.manage_file,
            },
        )

        patch_create = patch(
            "salt.modules.heat.create_stack",
            MagicMock(return_value={
                "result": True,
                "comment": "Created stack 'mystack'."
            }),
        )

        with patch_heat, patch_file, patch_create, self.patch_check:
            ret = heat.deployed(
                name="mystack",
                profile="openstack1",
                template=os.path.join(RUNTIME_VARS.BASE_FILES, "templates",
                                      "heat-template.yml"),
                poll=0,
            )
        assert ret == exp_ret