本文整理汇总了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(), '')
示例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()
示例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(), '')
示例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)
示例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(), "")
示例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(), '')
示例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(), "")
示例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(), "")
示例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'])
示例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)
示例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)
示例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)
示例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(), "")
示例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(), '')
示例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(), "")