def test_543334_HeatStackCreateWithURL(self):
        """ This test case checks creation of stack using template URL.

        Steps:
        1. Create stack using template URL.
        2. Check that the stack is in the list of stacks
        3. Check that stack status is 'CREATE_COMPLETE'
        4. Delete stack
        """
        stack_name = "empty__543334"
        template_url = (
            "https://raw.githubusercontent.com/tkuterina/"
            "mos-integration-tests/master/mos_tests/heat/"
            "templates/empty_heat_templ.yaml"
        )
        timeout = 20
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        stack_data = {
            "stack_name": stack_name,
            "template_url": template_url,
            "parameters": {"param": "some_param_string"},
            "timeout_mins": timeout,
        }
        output = self.heat.stacks.create(**stack_data)
        stack_id = output["stack"]["id"]
        self.uid_list.append(stack_id)
        stacks_id = [s.id for s in self.heat.stacks.list()]
        self.assertIn(stack_id, stacks_id)
        self.assertTrue(common_functions.check_stack_status(stack_name, self.heat, "CREATE_COMPLETE", timeout))
    def test_543336_HeatStackShow(self):
        """ This test case checks detailed stack's information.

        Steps:
        1. Create stack using template file empty_heat_templ.yaml
        2. Check that the stack is in the list of stacks
        3. Check that stack status is 'CREATE_COMPLETE'
        4. Check stack's information
        5. Delete stack
        """
        stack_name = "empty__543336"
        parameter = "some_param_string"
        timeout = 20
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        template = common_functions.read_template(self.templates_dir, "empty_heat_templ.yaml")
        uid = common_functions.create_stack(
            self.heat, stack_name, template, timeout=timeout, parameters={"param": parameter}
        )
        self.uid_list.append(uid)
        parameters = {
            "OS::project_id": self.keystone.auth_tenant_id,
            "OS::stack_id": uid,
            "OS::stack_name": stack_name,
            "param": parameter,
        }
        correct_data = {
            "description": "Sample template",
            "stack_name": stack_name,
            "disable_rollback": True,
            "template_description": "Sample template",
            "timeout_mins": timeout,
            "stack_status": "CREATE_COMPLETE",
            "id": uid,
            "stack_status_reason": "Stack CREATE completed " "successfully",
            "parameters": parameters,
        }
        output = self.heat.stacks.get(uid)
        show_data = {
            "description": output.description,
            "stack_name": output.stack_name,
            "disable_rollback": output.disable_rollback,
            "template_description": output.template_description,
            "timeout_mins": output.timeout_mins,
            "stack_status": output.stack_status,
            "id": output.id,
            "stack_status_reason": output.stack_status_reason,
            "parameters": output.parameters,
        }
        self.assertDictEqual(show_data, correct_data)
        self.assertEqual(len(output.links), 1)
        self.assertEqual(len(output.links[0]), 2)
        self.assertNotEqual(output.links[0]["href"].find(stack_name), -1)
        self.assertEqual(output.links[0]["rel"], "self")
    def test_543332_HeatStackPreview(self):
        """ This test case previews a stack.

        Steps:
        1. Execute stack preview.
        2. Check output result.
        """
        stack_name = "empty__543332"
        parameter = "some_param_string"
        parameters = {
            "OS::project_id": self.keystone.auth_tenant_id,
            "OS::stack_id": "None",
            "OS::stack_name": stack_name,
            "param": parameter,
        }
        correct_data = {
            "description": "Sample template",
            "stack_name": stack_name,
            "disable_rollback": True,
            "template_description": "Sample template",
            "parameters": parameters,
        }
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        template = common_functions.read_template(self.templates_dir, "empty_heat_templ.yaml")
        stack_data = {"stack_name": stack_name, "template": template, "parameters": {"param": parameter}}
        output = self.heat.stacks.preview(**stack_data)
        preview_data = {
            "description": output.description,
            "stack_name": output.stack_name,
            "disable_rollback": output.disable_rollback,
            "template_description": output.template_description,
            "parameters": output.parameters,
        }
        self.assertDictEqual(preview_data, correct_data)
        self.assertEqual(len(output.links), 1)
        self.assertEqual(len(output.links[0]), 2)
        self.assertNotEqual(output.links[0]["href"].find(stack_name), -1)
        self.assertEqual(output.links[0]["rel"], "self")
    def test_543333_HeatStackCreateWithTemplate(self):
        """ This test case checks creation of stack.

        Steps:
        1. Create stack using template file empty_heat_templ.yaml.
        2. Check that the stack is in the list of stacks
        3. Check that stack status is 'CREATE_COMPLETE'
        4. Delete stack
        """
        stack_name = "empty__543333"
        parameter = "some_param_string"
        timeout = 20
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        template = common_functions.read_template(self.templates_dir, "empty_heat_templ.yaml")
        uid = common_functions.create_stack(
            self.heat, stack_name, template, timeout=timeout, parameters={"param": parameter}
        )
        self.uid_list.append(uid)
        stacks_id = [s.id for s in self.heat.stacks.list()]
        self.assertIn(uid, stacks_id)
        self.assertTrue(common_functions.check_stack_status(stack_name, self.heat, "CREATE_COMPLETE", timeout))
    def test_543344_HeatStackTemplateShow(self):
        """ This test case checks representation of template of created stack.

        Steps:
        1. Create stack using template file empty_heat_templ.yaml.
        2. Check that template of created stack has correct \
        representation.
        """
        stack_name = "empty_stack"
        timeout = 60
        parameter = "some_string"
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        template = common_functions.read_template(self.templates_dir, "empty_heat_templ.yaml")
        uid = common_functions.create_stack(
            self.heat, stack_name, template, timeout=timeout, parameters={"param": parameter}
        )
        self.uid_list.append(uid)
        self.assertTrue(common_functions.check_stack_status(stack_name, self.heat, "CREATE_COMPLETE"))
        stack_dict = {s.stack_name: s.id for s in self.heat.stacks.list()}
        stack_id = stack_dict[stack_name]
        stack_template = self.heat.stacks.template(stack_id)
        self.assertIsInstance(stack_template, dict)
    def test_543335_HeatStackDelete(self):
        """ This test case checks deletion of stack.

        Steps:
        1. Create stack using template file empty_heat_templ.yaml.
        2. Check that the stack is in the list of stacks
        3. Delete the stack.
        4. Check that the stack is absent in the list of stacks

        """
        stack_name = "empty_543335"
        timeout = 20
        parameter = "some_param_string"
        if common_functions.is_stack_exists(stack_name, self.heat):
            uid = common_functions.get_stack_id(self.heat, stack_name)
            common_functions.delete_stack(self.heat, uid)
        template = common_functions.read_template(self.templates_dir, "empty_heat_templ.yaml")
        uid = common_functions.create_stack(
            self.heat, stack_name, template, timeout=timeout, parameters={"param": parameter}
        )
        self.assertTrue(common_functions.check_stack_status(stack_name, self.heat, "CREATE_COMPLETE", timeout))
        common_functions.delete_stack(self.heat, uid)
        stacks = [s.stack_name for s in self.heat.stacks.list()]
        self.assertNotIn(stack_name, stacks)