• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python fakes.FakeResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.unit.fakes.FakeResponse的典型用法代码示例。如果您正苦于以下问题:Python FakeResponse类的具体用法?Python FakeResponse怎么用?Python FakeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FakeResponse类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_container_cdn_metadata

 def test_get_container_cdn_metadata(self):
     client = self.client
     client.connection.cdn_request = Mock()
     resp = FakeResponse()
     resp.headers = [("a", "b"), ("c", "d")]
     client.connection.cdn_request.return_value = resp
     returned = client.get_container_cdn_metadata(self.cont_name)
     expected = {"a": "b", "c": "d"}
     self.assertEqual(expected, returned)
开发者ID:datalogics,项目名称:pyrax,代码行数:9,代码来源:test_cf_client.py


示例2: test_make_private

 def test_make_private(self):
     cont = self.container
     cont.client.connection.cdn_request = Mock()
     example = "http://example.com"
     cont.cdn_uri = example
     resp = FakeResponse()
     resp.headers = [("c", "d")]
     cont.client.connection.cdn_request.return_value = resp
     cont.make_private()
     cont.client.connection.cdn_request.assert_called_with("PUT",
             [cont.name], hdrs={"X-CDN-Enabled": "False"})
开发者ID:jirwin,项目名称:pyrax,代码行数:11,代码来源:test_cf_container.py


示例3: test_list_public_containers

 def test_list_public_containers(self):
     client = self.client
     client.connection.cdn_request = Mock()
     resp = FakeResponse()
     resp.headers = [("a", "b"), ("c", "d")]
     resp.status = 500
     client.connection.cdn_request.return_value = resp
     self.assertRaises(exc.CDNFailed, client.list_public_containers)
     resp.status = 200
     conts = client.list_public_containers()
     client.connection.cdn_request.assert_called_with("GET", [""])
     self.assertEqual(len(conts), 2)
开发者ID:datalogics,项目名称:pyrax,代码行数:12,代码来源:test_cf_client.py


示例4: test_make_public

 def test_make_public(self, ttl=None):
     cont = self.container
     cont.cdn_uri = ""
     cont.client.connection.cdn_request = Mock()
     example = "http://example.com"
     ttl = 6666
     resp = FakeResponse()
     resp.headers = [("x-cdn-uri", example), ("c", "d")]
     cont.client.connection.cdn_request.return_value = resp
     cont.make_public(ttl)
     cont.client.connection.cdn_request.assert_called_with("PUT",
             [cont.name], hdrs={"X-TTL": str(ttl), "X-CDN-Enabled": "True"})
开发者ID:jirwin,项目名称:pyrax,代码行数:12,代码来源:test_cf_container.py


示例5: test_set_cdn_log_retention

 def test_set_cdn_log_retention(self):
     client = self.client
     client.connection.head_container = Mock()
     cont = client.get_container(self.cont_name)
     client.connection.cdn_request = Mock()
     resp = FakeResponse()
     client.connection.cdn_request.return_value = resp
     resp.status = 500
     self.assertRaises(exc.CDNFailed, client.set_cdn_log_retention, cont, True)
     resp.status = 204
     client.set_cdn_log_retention(cont, True)
     self.assert_(cont.cdn_log_retention)
     client.set_cdn_log_retention(cont, False)
     self.assertFalse(cont.cdn_log_retention)
开发者ID:dustinfarris,项目名称:pyrax,代码行数:14,代码来源:test_cf_client.py


示例6: test_fetch_cdn_not_found

 def test_fetch_cdn_not_found(self):
     self.client.connection.cdn_request = Mock()
     resp = FakeResponse()
     resp.status = 404
     resp.getheaders = Mock()
     test_uri = "http://example.com"
     test_ttl = "6666"
     test_ssl_uri = "http://ssl.example.com"
     test_streaming_uri = "http://streaming.example.com"
     test_log_retention = True
     resp.getheaders.return_value = []
     self.client.connection.cdn_request.return_value = resp
     # We need an actual container
     cont = Container(self.client, "realcontainer", 0, 0)
     self.assertIsNone(cont.cdn_uri)
开发者ID:jirwin,项目名称:pyrax,代码行数:15,代码来源:test_cf_container.py


示例7: test_make_container_private

 def test_make_container_private(self):
     client = self.client
     client.connection.head_container = Mock()
     cont = client.get_container(self.cont_name)
     cont.cdn_uri = None
     client.connection.cdn_request = Mock()
     example = "http://example.com"
     resp = FakeResponse()
     resp.headers = [("x-cdn-uri", example), ("c", "d")]
     resp.status = 500
     client.connection.cdn_request.return_value = resp
     self.assertRaises(exc.CDNFailed, client.make_container_public, self.cont_name)
     resp.status = 204
     client.make_container_private(self.cont_name)
     client.connection.cdn_request.assert_called_with("PUT", [self.cont_name], hdrs={"X-CDN-Enabled": "False"})
开发者ID:piecommerce,项目名称:pyrax,代码行数:15,代码来源:test_cf_client.py


示例8: test_fetch_cdn

 def test_fetch_cdn(self):
     self.client.connection.cdn_request = Mock()
     resp = FakeResponse()
     resp.status = 204
     resp.getheaders = Mock()
     test_uri = "http://example.com"
     test_ttl = "6666"
     test_ssl_uri = "http://ssl.example.com"
     test_streaming_uri = "http://streaming.example.com"
     test_log_retention = True
     resp.getheaders.return_value = [("x-cdn-uri", test_uri), ("x-ttl", test_ttl),
             ("x-cdn-ssl-uri", test_ssl_uri), ("x-cdn-streaming-uri", test_streaming_uri),
             ("x-log-retention", test_log_retention)]
     self.client.connection.cdn_request.return_value = resp
     # We need an actual container
     cont = Container(self.client, "realcontainer", 0, 0)
     self.assertEqual(cont.cdn_uri, test_uri)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:17,代码来源:test_cf_container.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python resources.test_root_certificates函数代码示例发布时间:2022-05-27
下一篇:
Python utils.query_columns函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap