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


Python CLI.main方法代码示例

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


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

示例1: test_post_container

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_post_container(self):
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['post', self.container, '-h',
                     'x-container-meta-swiftly-test:one'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head', self.container])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        stdout = \
            dict(x.split(':', 1) for x in stdout.getvalue().split('\n') if x)
        self.assertEquals(
            sorted(stdout.keys()),
            ['X-Container-Bytes-Used', 'X-Container-Meta-Swiftly-Test',
             'X-Container-Object-Count', 'X-Timestamp'])
        self.assertEquals(stderr.getvalue(), '')
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:28,代码来源:test_post.py

示例2: tearDown

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def tearDown(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(["delete", self.container, "--recursive"])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     cli.main()
开发者ID:dani4571,项目名称:swiftly,代码行数:9,代码来源:test_head.py

示例3: test_post_obj

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_post_obj(self):
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['post', self.obj, '-h', 'x-object-meta-swiftly-test:one'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head', self.obj])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        stdout = \
            dict(x.split(':', 1) for x in stdout.getvalue().split('\n') if x)
        self.assertEquals(
            sorted(stdout.keys()),
            ['Content-Length', 'Content-Type', 'Etag', 'Last-Modified',
             'X-Object-Meta-Swiftly-Test', 'X-Timestamp'])
        self.assertEquals(stdout['Content-Length'].strip(), '9')
        self.assertEquals(stdout['Content-Type'].strip(),
                          'application/octet-stream')
        self.assertEquals(stdout['Etag'].strip(),
                          'e9de89b0a5e9ad6efd5e5ab543ec617c')
        self.assertEquals(stdout['X-Object-Meta-Swiftly-Test'].strip(),
                          'one')
        self.assertEquals(stderr.getvalue(), '')
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:34,代码来源:test_post.py

示例4: test_post_account

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_post_account(self):
        uuid = uuid4().hex
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(
            ['post', '-h', 'x-account-meta-swiftly-test-%s:one' % uuid])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        stdout = \
            dict(x.split(':', 1) for x in stdout.getvalue().split('\n') if x)
        self.assertTrue('X-Account-Bytes-Used' in stdout)
        self.assertTrue('X-Account-Container-Count' in stdout)
        self.assertTrue('X-Account-Object-Count' in stdout)
        self.assertTrue(
            ('X-Account-Meta-Swiftly-Test-%s' % uuid).title() in stdout)
        self.assertEquals(stderr.getvalue(), '')

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(
            ['post', '-h', 'x-account-meta-swiftly-test-%s:' % uuid])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        stdout = \
            dict(x.split(':', 1) for x in stdout.getvalue().split('\n') if x)
        self.assertTrue('X-Account-Bytes-Used' in stdout)
        self.assertTrue('X-Account-Container-Count' in stdout)
        self.assertTrue('X-Account-Object-Count' in stdout)
        self.assertTrue(
            ('X-Account-Meta-Swiftly-Test-%s' % uuid).title() not in stdout)
        self.assertEquals(stderr.getvalue(), '')
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:57,代码来源:test_post.py

示例5: test_help_command

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_help_command(self):
     stdout = StringIO()
     stderr = StringIO()
     cli = CLI(args=['help', 'head'], stdout=stdout, stderr=stderr)
     rv = cli.main()
     stdout = stdout.getvalue()
     stderr = stderr.getvalue()
     self.assertEquals(rv, 1)
     self.assertTrue('Usage:' in stdout, stdout)
     self.assertTrue(not stderr)
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:12,代码来源:test_help.py

示例6: test_get_container

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_get_container(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(['get', self.container])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     rv = cli.main()
     self.assertEquals(rv, 0)
     self.assertEquals(stdout.getvalue(), 'test\n')
     self.assertEquals(stderr.getvalue(), '')
开发者ID:dani4571,项目名称:swiftly,代码行数:12,代码来源:test_get.py

示例7: test_get_obj

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_get_obj(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(["get", self.obj])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     rv = cli.main()
     self.assertEquals(rv, 0)
     self.assertEquals(stdout.getvalue(), "testvalue")
     self.assertEquals(stderr.getvalue(), "")
开发者ID:rgbkrk,项目名称:swiftly,代码行数:12,代码来源:test_get.py

示例8: test_get_account

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_get_account(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(["get"])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     rv = cli.main()
     self.assertEquals(rv, 0)
     self.assertTrue(self.container in stdout.getvalue())
     self.assertEquals(stderr.getvalue(), "")
开发者ID:rgbkrk,项目名称:swiftly,代码行数:12,代码来源:test_get.py

示例9: test_delete_recursive

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_delete_recursive(self):
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['delete', self.container])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 1)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue().split(), ['409', 'Conflict'])

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['delete', self.container, '--recursive'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:22,代码来源:test_delete.py

示例10: setUp

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def setUp(self):
        self.uuid = uuid4().hex
        self.container = 'swiftly_test_' + self.uuid
        self.obj = 'swiftly_test_' + self.uuid + '/test'

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['put', self.container])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()

        stdin = StringIO('testvalue')
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['put', self.obj])
        cli = CLI(args=args, stdin=stdin, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:22,代码来源:test_head.py

示例11: test_head_obj_ignore_404

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_head_obj_ignore_404(self):
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head', self.obj + '2'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 1)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue().split(), ['404', 'Not', 'Found'])

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(['head', self.obj + '2', '--ignore-404'])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), '')
        self.assertEquals(stderr.getvalue(), '')
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:22,代码来源:test_head.py

示例12: test_head_container

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_head_container(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(["head", self.container])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     rv = cli.main()
     self.assertEquals(rv, 0)
     stdout = dict(x.split(":", 1) for x in stdout.getvalue().split("\n") if x)
     self.assertEquals(sorted(stdout.keys()), ["X-Container-Bytes-Used", "X-Container-Object-Count"])
     self.assertEquals(stderr.getvalue(), "")
开发者ID:dani4571,项目名称:swiftly,代码行数:13,代码来源:test_head.py

示例13: test_head_obj_ignore_404

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
    def test_head_obj_ignore_404(self):
        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(["head", self.obj + "2"])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 1)
        self.assertEquals(stdout.getvalue(), "")
        self.assertEquals(stderr.getvalue().split(), ["404", "Not", "Found"])

        stdout = StringIO()
        stderr = StringIO()
        args = list(self.start_args)
        args.extend(["head", self.obj + "2", "--ignore-404"])
        cli = CLI(args=args, stdout=stdout, stderr=stderr)
        rv = cli.main()
        self.assertEquals(rv, 0)
        self.assertEquals(stdout.getvalue(), "")
        self.assertEquals(stderr.getvalue(), "")
开发者ID:dani4571,项目名称:swiftly,代码行数:22,代码来源:test_head.py

示例14: test_get_account_raw

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_get_account_raw(self):
     stdout = StringIO()
     stderr = StringIO()
     args = list(self.start_args)
     args.extend(['get', '-r'])
     cli = CLI(args=args, stdout=stdout, stderr=stderr)
     rv = cli.main()
     self.assertEquals(rv, 0)
     stdout = json.loads(stdout.getvalue())
     self.assertTrue(len(stdout))
     stdout = stdout[0]
     self.assertEquals(sorted(stdout.keys()), ['bytes', 'count', 'name'])
开发者ID:dani4571,项目名称:swiftly,代码行数:14,代码来源:test_get.py

示例15: test_help_invalid_command

# 需要导入模块: from swiftly.cli import CLI [as 别名]
# 或者: from swiftly.cli.CLI import main [as 别名]
 def test_help_invalid_command(self):
     stdout = StringIO()
     stderr = StringIO()
     cli = CLI(args=['help', 'slkdfjsdkfj'], stdout=stdout, stderr=stderr)
     rv = cli.main()
     stdout = stdout.getvalue()
     stderr = stderr.getvalue()
     self.assertEquals(rv, 1)
     self.assertTrue('Usage:' in stdout, stdout)
     self.assertTrue('Options:' in stdout, stdout)
     self.assertTrue('Commands:' in stdout, stdout)
     self.assertTrue(not stderr)
开发者ID:jonkelleyatrackspace,项目名称:swiftly,代码行数:14,代码来源:test_help.py


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