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


Python Status.key方法代码示例

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

#.........这里部分代码省略.........
开发者ID:2do,项目名称:stashboard,代码行数:103,代码来源:test_rest_status.py


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