本文整理汇总了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