本文整理汇总了Python中models.Status.key方法的典型用法代码示例。如果您正苦于以下问题:Python Status.key方法的具体用法?Python Status.key怎么用?Python Status.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StatusInstanceTest
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import key [as 别名]
class StatusInstanceTest(StashboardTest):
def setUp(self):
super(StatusInstanceTest, self).setUp()
image = Image(icon_set="fugue", slug="cross-circle",
path="fugue/cross-circle.png")
image.put()
self.status = Status(name="Foo", slug="foo", description="bar",
image="cross-circle")
self.status.put()
def test_update_wrong_image(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"image": "foobar"})
self.assertEquals(response.status_code, 400)
def test_update_default_false(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"default": "false"})
self.assertEquals(response.status_code, 200)
status = Status.get(self.status.key())
self.assertFalse(status.default)
def test_update_default(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"default": "true"})
self.assertEquals(response.status_code, 200)
status = Status.get(self.status.key())
self.assertTrue(status.default)
def test_update_image(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"image": "cross-circle"})
self.assertEquals(response.status_code, 200)
status = Status.get(self.status.key())
self.assertEquals(status.image, "fugue/cross-circle.png")
def test_update_description(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"description": "blah"})
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
status = Status.get(self.status.key())
self.assertEquals(status.description, "blah")
def test_update_name(self):
response = self.post("/admin/api/v1/statuses/foo",
data={"name": "Foobar"})
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
status = Status.get(self.status.key())
self.assertEquals(status.name, "Foobar")
def test_get_wrong_status(self):
response = self.get("/api/v1/statuses/bat")
self.assertEquals(response.status_code, 404)
self.assertEquals(response.headers["Content-Type"], "application/json")
def test_get_status(self):
response = self.get("/api/v1/statuses/foo")
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
def test_url_api_correct(self):
response = self.get("/admin/api/v1/statuses/foo")
data = json.loads(response.content)
self.assertEquals(data['url'], 'http://localhost:80/admin/api/v1/statuses/foo')
def test_url_admin_api_correct(self):
response = self.get("/api/v1/statuses/foo")
data = json.loads(response.content)
self.assertEquals(data['url'], 'http://localhost:80/api/v1/statuses/foo')
def test_delete_success(self):
response = self.delete("/admin/api/v1/statuses/foo")
self.assertEquals(response.status_code, 200)
self.assertEquals(response.headers["Content-Type"], "application/json")
data = json.loads(response.content)
self.assertEquals(data['url'], 'http://localhost:80/admin/api/v1/statuses/foo')
status = Status.get(self.status.key())
self.assertEquals(status, None)
def test_delete_no_slug(self):
response = self.delete("/admin/api/v1/statuses/bar")
self.assertEquals(response.status_code, 404)
self.assertEquals(response.headers["Content-Type"], "application/json")
def test_delete_wrong_version(self):
response = self.delete("/admin/api/hey/statuses/foo")
self.assertEquals(response.status_code, 404)
self.assertEquals(response.headers["Content-Type"], "application/json")
#.........这里部分代码省略.........