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


Python info.print_obj函数代码示例

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


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

示例1: test_print_obj_valid

 def test_print_obj_valid(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile, swift_dir=self.testdir)
     etag_msg = 'ETag: Not found in metadata'
     length_msg = 'Content-Length: Not found in metadata'
     self.assertTrue(etag_msg in out.getvalue())
     self.assertTrue(length_msg in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:8,代码来源:test_info.py

示例2: test_print_obj_no_ring

    def test_print_obj_no_ring(self):
        no_rings_dir = os.path.join(self.testdir, 'no_rings_here')
        os.mkdir(no_rings_dir)

        out = StringIO()
        with mock.patch('sys.stdout', out):
            print_obj(self.datafile, swift_dir=no_rings_dir)
        self.assertTrue('d41d8cd98f00b204e9800998ecf8427e' in out.getvalue())
        self.assertTrue('Partition' not in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:9,代码来源:test_info.py

示例3: test_print_obj_meta_and_ts_files

 def test_print_obj_meta_and_ts_files(self):
     # verify that print_obj will also read from meta and ts files
     base = os.path.splitext(self.datafile)[0]
     for ext in ('.meta', '.ts'):
         test_file = '%s%s' % (base, ext)
         os.link(self.datafile, test_file)
         out = StringIO()
         with mock.patch('sys.stdout', out):
             print_obj(test_file, swift_dir=self.testdir)
         self.assertTrue('/objects-1/' in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:10,代码来源:test_info.py

示例4: test_print_obj_with_policy

 def test_print_obj_with_policy(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile, swift_dir=self.testdir, policy_name='one')
     etag_msg = 'ETag: Not found in metadata'
     length_msg = 'Content-Length: Not found in metadata'
     ring_loc_msg = 'ls -lah'
     self.assertTrue(etag_msg in out.getvalue())
     self.assertTrue(length_msg in out.getvalue())
     self.assertTrue(ring_loc_msg in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:10,代码来源:test_info.py

示例5: test_invalid_etag

    def test_invalid_etag(self):
        with open(self.datafile, 'wb') as fp:
            md = {'name': '/AUTH_admin/c/obj',
                  'Content-Type': 'application/octet-stream',
                  'ETag': 'badetag',
                  'Content-Length': 0}
            write_metadata(fp, md)

        out = StringIO()
        with mock.patch('sys.stdout', out):
            print_obj(self.datafile)
        self.assertTrue('ETag: badetag doesn\'t match file hash'
                        in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:13,代码来源:test_info.py

示例6: test_print_obj_policy_index

    def test_print_obj_policy_index(self):
        # Check an output of policy index when current directory is in
        # object-* directory
        out = StringIO()
        hash_dir = os.path.dirname(self.datafile)
        file_name = os.path.basename(self.datafile)

        # Change working directory to object hash dir
        cwd = os.getcwd()
        try:
            os.chdir(hash_dir)
            with mock.patch('sys.stdout', out):
                print_obj(file_name, swift_dir=self.testdir)
        finally:
            os.chdir(cwd)
        self.assertTrue('X-Backend-Storage-Policy-Index: 1' in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:16,代码来源:test_info.py

示例7: test_print_obj_curl_command_ipv6

    def test_print_obj_curl_command_ipv6(self):
        # Note: policy 3 has IPv6 addresses in its ring
        datafile3 = os.path.join(
            self.testdir,
            'sda', 'objects-3', '1', 'ea8',
            'db4449e025aca992307c7c804a67eea8', '1402017884.18202.data')
        utils.mkdirs(os.path.dirname(datafile3))
        with open(datafile3, 'wb') as fp:
            md = {'name': '/AUTH_admin/c/obj',
                  'Content-Type': 'application/octet-stream',
                  'ETag': 'd41d8cd98f00b204e9800998ecf8427e',
                  'Content-Length': 0}
            write_metadata(fp, md)

        object_ring = ring.Ring(self.testdir, ring_name='object-3')
        part, nodes = object_ring.get_nodes('AUTH_admin', 'c', 'obj')
        node = nodes[0]

        out = StringIO()
        hash_dir = os.path.dirname(datafile3)
        file_name = os.path.basename(datafile3)

        # Change working directory to object hash dir
        cwd = os.getcwd()
        try:
            os.chdir(hash_dir)
            with mock.patch('sys.stdout', out):
                print_obj(file_name, swift_dir=self.testdir)
        finally:
            os.chdir(cwd)

        exp_curl = (
            'curl -g -I -XHEAD '
            '"http://[{host}]:{port}'
            '/{device}/{part}/AUTH_admin/c/obj" ').format(
                host=node['ip'],
                port=node['port'],
                device=node['device'],
                part=part)
        self.assertIn(exp_curl, out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:40,代码来源:test_info.py

示例8: test_unchecked_etag

 def test_unchecked_etag(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile, check_etag=False)
     self.assertTrue('ETag: d41d8cd98f00b204e9800998ecf8427e (not checked)'
                     in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:6,代码来源:test_info.py

示例9: test_print_obj_policy_name_mismatch

 def test_print_obj_policy_name_mismatch(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile, policy_name='two', swift_dir=self.testdir)
     ring_alert_msg = 'Warning: Ring does not match policy!'
     self.assertTrue(ring_alert_msg in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:6,代码来源:test_info.py

示例10: test_print_obj

 def test_print_obj(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile, swift_dir=self.testdir)
     self.assertTrue('/objects-1/' in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:5,代码来源:test_info.py

示例11: test_missing_etag

 def test_missing_etag(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile)
     self.assertTrue('ETag: Not found in metadata' in out.getvalue())
开发者ID:aureliengoulon,项目名称:swift,代码行数:5,代码来源:test_info.py

示例12: test_valid_etag

 def test_valid_etag(self):
     out = StringIO()
     with mock.patch('sys.stdout', out):
         print_obj(self.datafile)
     self.assertIn('ETag: d41d8cd98f00b204e9800998ecf8427e (valid)',
                   out.getvalue())
开发者ID:bebule,项目名称:swift,代码行数:6,代码来源:test_info.py


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