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


Python Service.key方法代码示例

本文整理汇总了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")
开发者ID:BillTheBest,项目名称:stashboard,代码行数:60,代码来源:test_services.py


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