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


Python Controller._get_shard_ranges方法代码示例

本文整理汇总了Python中swift.proxy.controllers.base.Controller._get_shard_ranges方法的典型用法代码示例。如果您正苦于以下问题:Python Controller._get_shard_ranges方法的具体用法?Python Controller._get_shard_ranges怎么用?Python Controller._get_shard_ranges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.proxy.controllers.base.Controller的用法示例。


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

示例1: test_get_shard_ranges_for_object_put

# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import _get_shard_ranges [as 别名]
    def test_get_shard_ranges_for_object_put(self):
        ts_iter = make_timestamp_iter()
        shard_ranges = [dict(ShardRange(
            '.sharded_a/sr%d' % i, next(ts_iter), '%d_lower' % i,
            '%d_upper' % i, object_count=i, bytes_used=1024 * i,
            meta_timestamp=next(ts_iter)))
            for i in range(3)]
        base = Controller(self.app)
        req = Request.blank('/v1/a/c/o', method='PUT')
        resp_headers = {'X-Backend-Record-Type': 'shard'}
        with mocked_http_conn(
            200, 200,
            body_iter=iter([b'',
                            json.dumps(shard_ranges[1:2]).encode('ascii')]),
            headers=resp_headers
        ) as fake_conn:
            actual = base._get_shard_ranges(req, 'a', 'c', '1_test')

        # account info
        captured = fake_conn.requests
        self.assertEqual('HEAD', captured[0]['method'])
        self.assertEqual('a', captured[0]['path'][7:])
        # container GET
        self.assertEqual('GET', captured[1]['method'])
        self.assertEqual('a/c', captured[1]['path'][7:])
        params = sorted(captured[1]['qs'].split('&'))
        self.assertEqual(
            ['format=json', 'includes=1_test'], params)
        self.assertEqual(
            'shard', captured[1]['headers'].get('X-Backend-Record-Type'))
        self.assertEqual(shard_ranges[1:2], [dict(pr) for pr in actual])
        self.assertFalse(self.app.logger.get_lines_for_level('error'))
开发者ID:mahak,项目名称:swift,代码行数:34,代码来源:test_base.py

示例2: test_get_shard_ranges_request_failed

# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import _get_shard_ranges [as 别名]
 def test_get_shard_ranges_request_failed(self):
     base = Controller(self.app)
     req = Request.blank('/v1/a/c/o', method='PUT')
     with mocked_http_conn(200, 404, 404, 404):
         actual = base._get_shard_ranges(req, 'a', 'c', '1_test')
     self.assertIsNone(actual)
     self.assertFalse(self.app.logger.get_lines_for_level('error'))
     warning_lines = self.app.logger.get_lines_for_level('warning')
     self.assertIn('Failed to get container listing', warning_lines[0])
     self.assertIn('/a/c', warning_lines[0])
     self.assertFalse(warning_lines[1:])
开发者ID:mahak,项目名称:swift,代码行数:13,代码来源:test_base.py

示例3: _check_get_shard_ranges_bad_data

# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import _get_shard_ranges [as 别名]
 def _check_get_shard_ranges_bad_data(self, body):
     base = Controller(self.app)
     req = Request.blank('/v1/a/c/o', method='PUT')
     # empty response
     headers = {'X-Backend-Record-Type': 'shard'}
     with mocked_http_conn(200, 200, body_iter=iter([b'', body]),
                           headers=headers):
         actual = base._get_shard_ranges(req, 'a', 'c', '1_test')
     self.assertIsNone(actual)
     lines = self.app.logger.get_lines_for_level('error')
     return lines
开发者ID:mahak,项目名称:swift,代码行数:13,代码来源:test_base.py

示例4: test_get_shard_ranges_missing_record_type

# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import _get_shard_ranges [as 别名]
 def test_get_shard_ranges_missing_record_type(self):
     base = Controller(self.app)
     req = Request.blank('/v1/a/c/o', method='PUT')
     sr = ShardRange('a/c', Timestamp.now())
     body = json.dumps([dict(sr)]).encode('ascii')
     with mocked_http_conn(
             200, 200, body_iter=iter([b'', body])):
         actual = base._get_shard_ranges(req, 'a', 'c', '1_test')
     self.assertIsNone(actual)
     error_lines = self.app.logger.get_lines_for_level('error')
     self.assertIn('Failed to get shard ranges', error_lines[0])
     self.assertIn('unexpected record type', error_lines[0])
     self.assertIn('/a/c', error_lines[0])
     self.assertFalse(error_lines[1:])
开发者ID:mahak,项目名称:swift,代码行数:16,代码来源:test_base.py


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