当前位置: 首页>>代码示例>>Python>>正文


Python Template.delete方法代码示例

本文整理汇总了Python中marvin.lib.base.Template.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Template.delete方法的具体用法?Python Template.delete怎么用?Python Template.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.lib.base.Template的用法示例。


在下文中一共展示了Template.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_01_list_templates_pagination

# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import delete [as 别名]

#.........这里部分代码省略.........
        self.assertEquals(
            PASS,
            status[0],
            "Templates creation failed"
        )
        # Verifying that list size is pagesize + 1
        self.assertEquals(
            self.services["pagesize"] + 1,
            len(list_templates_after),
            "Failed to create pagesize + 1 number of Templates"
        )
        # Listing all the Templates in page 1
        list_templates_page1 = Template.list(
            self.userapiclient,
            listall=self.services["listall"],
            templatefilter=self.services["templatefilter"],
            page=1,
            pagesize=self.services["pagesize"]
        )
        status = validateList(list_templates_page1)
        self.assertEquals(
            PASS,
            status[0],
            "Failed to list Templates in page 1"
        )
        # Verifying the list size to be equal to pagesize
        self.assertEquals(
            self.services["pagesize"],
            len(list_templates_page1),
            "Size of Templates in page 1 is not matching"
        )
        # Listing all the Templates in page 2
        list_templates_page2 = Template.list(
            self.userapiclient,
            listall=self.services["listall"],
            templatefilter=self.services["templatefilter"],
            page=2,
            pagesize=self.services["pagesize"]
        )
        status = validateList(list_templates_page2)
        self.assertEquals(
            PASS,
            status[0],
            "Failed to list Templates in page 2"
        )
        # Verifying the list size to be equal to 1
        self.assertEquals(
            1,
            len(list_templates_page2),
            "Size of Templates in page 2 is not matching"
        )
        # Verifying the state of the template to be ready. If not waiting for
        # state to become ready
        template_ready = False
        count = 0
        while template_ready is False:
            list_template = Template.list(
                self.userapiclient,
                id=template_created.id,
                listall=self.services["listall"],
                templatefilter=self.services["templatefilter"],
            )
            status = validateList(list_template)
            self.assertEquals(
                PASS,
                status[0],
                "Failed to list Templates by Id"
            )
            if list_template[0].isready is True:
                template_ready = True
            elif (str(list_template[0].status) == "Error"):
                self.fail("Created Template is in Errored state")
                break
            elif count > 10:
                self.fail("Timed out before Template came into ready state")
                break
            else:
                time.sleep(self.services["sleep"])
                count = count + 1

        # Deleting the Template present in page 2
        Template.delete(
            template_created,
            self.userapiclient
        )
        # Listing all the Templates in page 2 again
        list_templates_page2 = Template.list(
            self.userapiclient,
            listall=self.services["listall"],
            templatefilter=self.services["templatefilter"],
            page=2,
            pagesize=self.services["pagesize"]
        )
        # Verifying that there are no Templates listed
        self.assertIsNone(
            list_templates_page2,
            "Templates not deleted from page 2"
        )
        del self.services["privatetemplate"]["ostype"]
        return
开发者ID:K0zka,项目名称:cloudstack,代码行数:104,代码来源:test_escalations_templates.py


注:本文中的marvin.lib.base.Template.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。