本文整理汇总了Python中models.Service.key方法的典型用法代码示例。如果您正苦于以下问题:Python Service.key方法的具体用法?Python Service.key怎么用?Python Service.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Service
的用法示例。
在下文中一共展示了Service.key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ServiceInstanceTest
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import key [as 别名]
class ServiceInstanceTest(StashboardTest):
def setUp(self):
super(ServiceInstanceTest, self).setUp()
self.service = Service(name="Foo", slug="foo", description="foo")
self.service.put()
@patch("handlers.api.invalidate_cache")
def test_delete_service(self, mock):
response = self.delete("/admin/api/v1/services/foo")
self.assertEquals(response.status_code, 200)
def test_delete_wrong_service(self):
response = self.delete("/admin/api/v1/services/bar")
self.assertEquals(response.status_code, 404)
def test_delete_wrong_version(self):
response = self.delete("/admin/api/foo/services/foo")
self.assertEquals(response.status_code, 404)
def test_post_wrong_service(self):
response = self.post("/admin/api/v1/services/bar")
self.assertEquals(response.status_code, 404)
def test_post_wrong_version(self):
response = self.post("/admin/api/foo/services/foo")
self.assertEquals(response.status_code, 404)
def test_post_update_desc(self):
response = self.post("/admin/api/v1/services/foo",
data={"description": "hello"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = Service.get(self.service.key())
self.assertEquals(service.description, "hello")
def test_post_update(self):
response = self.post("/admin/api/v1/services/foo",
data={"name": "bar"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = Service.get(self.service.key())
self.assertEquals(service.name, "bar")
def test_get_wrong_service(self):
response = self.get("/admin/api/v1/services/bar")
self.assertEquals(response.status_code, 404)
def test_get_wrong_version(self):
response = self.get("/admin/api/foo/services/foo")
self.assertEquals(response.status_code, 404)
def test_get_service(self):
response = self.get("/admin/api/v1/services/foo")
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")