當前位置: 首頁>>代碼示例>>Python>>正文


Python cli.CLI類代碼示例

本文整理匯總了Python中swiftly.cli.CLI的典型用法代碼示例。如果您正苦於以下問題:Python CLI類的具體用法?Python CLI怎麽用?Python CLI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CLI類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_post_container

    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,代碼行數:26,代碼來源:test_post.py

示例2: tearDown

 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,代碼行數:7,代碼來源:test_head.py

示例3: test_post_obj

    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,代碼行數:32,代碼來源:test_post.py

示例4: test_help_command

 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,代碼行數:10,代碼來源:test_help.py

示例5: test_get_obj

 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,代碼行數:10,代碼來源:test_get.py

示例6: test_get_container

 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,代碼行數:10,代碼來源:test_get.py

示例7: test_get_account

 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,代碼行數:10,代碼來源:test_get.py

示例8: test_head_container

 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,代碼行數:11,代碼來源:test_head.py

示例9: test_get_account_raw

 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,代碼行數:12,代碼來源:test_get.py

示例10: test_help_invalid_command

 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,代碼行數:12,代碼來源:test_help.py

示例11: test_invalid_args

 def test_invalid_args(self):
     stdout = StringIO()
     stderr = StringIO()
     cli = CLI(args=['asfsdasdf'], 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,代碼行數:12,代碼來源:test_help.py

示例12: test_direct

 def test_direct(self):
     stdout = StringIO()
     stderr = StringIO()
     cli = CLI(args=['-D', SWIFT_PROXY_STORAGE_PATH, 'auth'], stdout=stdout,
               stderr=stderr)
     rv = cli.main()
     stdout = stdout.getvalue()
     stderr = stderr.getvalue()
     self.assertEquals(rv, 0)
     stdout = stdout.split()
     self.assertEquals(stdout,
                       ['Direct', 'Storage', 'Path:', '/v1/AUTH_test'])
     self.assertTrue(not stderr)
開發者ID:dani4571,項目名稱:swiftly,代碼行數:13,代碼來源:test_auth.py

示例13: test_head_account

 def test_head_account(self):
     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.assertEquals(stderr.getvalue(), "")
開發者ID:dani4571,項目名稱:swiftly,代碼行數:13,代碼來源:test_head.py

示例14: test_head_account

 def test_head_account(self):
     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.assertEquals(stderr.getvalue(), '')
開發者ID:jonkelleyatrackspace,項目名稱:swiftly,代碼行數:14,代碼來源:test_head.py

示例15: test_head_obj

 def test_head_obj(self):
     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"])
     self.assertEquals(stdout["Content-Length"].strip(), "9")
     self.assertEquals(stdout["Content-Type"].strip(), "application/octet-stream")
     self.assertEquals(stdout["Etag"].strip(), "e9de89b0a5e9ad6efd5e5ab543ec617c")
     self.assertEquals(stderr.getvalue(), "")
開發者ID:dani4571,項目名稱:swiftly,代碼行數:14,代碼來源:test_head.py


注:本文中的swiftly.cli.CLI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。