本文整理汇总了Python中swiftly.cli.CLI类的典型用法代码示例。如果您正苦于以下问题:Python CLI类的具体用法?Python CLI怎么用?Python CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_get_container_full
def test_get_container_full(self):
stdout = StringIO()
stderr = StringIO()
args = list(self.start_args)
args.extend(['get', self.container, '-f'])
cli = CLI(args=args, stdout=stdout, stderr=stderr)
rv = cli.main()
self.assertEquals(rv, 0)
stdout = stdout.getvalue().split()
self.assertEquals(len(stdout), 6)
self.assertEquals(stdout[0], '9')
self.assertEquals(stdout[3], 'e9de89b0a5e9ad6efd5e5ab543ec617c')
self.assertEquals(stdout[4], 'application/octet-stream')
self.assertEquals(stdout[5], 'test')
self.assertEquals(stderr.getvalue(), '')
开发者ID:dani4571,项目名称:swiftly,代码行数:15,代码来源:test_get.py
示例17: test_get_container_full
def test_get_container_full(self):
stdout = StringIO()
stderr = StringIO()
args = list(self.start_args)
args.extend(["get", self.container, "-f"])
cli = CLI(args=args, stdout=stdout, stderr=stderr)
rv = cli.main()
self.assertEquals(rv, 0)
stdout = stdout.getvalue().split()
self.assertEquals(len(stdout), 6)
self.assertEquals(stdout[0], "9")
self.assertEquals(stdout[3], "e9de89b0a5e9ad6efd5e5ab543ec617c")
self.assertEquals(stdout[4], "application/octet-stream")
self.assertEquals(stdout[5], "test")
self.assertEquals(stderr.getvalue(), "")
开发者ID:rgbkrk,项目名称:swiftly,代码行数:15,代码来源:test_get.py
示例18: test_client
def test_client(self):
stdout = StringIO()
stderr = StringIO()
cli = CLI(
args=['-A', AUTH_URL, '-U', AUTH_USER, '-K', AUTH_KEY, 'auth'],
stdout=stdout, stderr=stderr)
rv = cli.main()
stdout = stdout.getvalue()
stderr = stderr.getvalue()
self.assertEquals(rv, 0)
stdout = stdout.split()
self.assertEquals(stdout[:2], ['Storage', 'URL:'])
urlparse(stdout[2])
self.assertEquals(stdout[3:-1], ['Auth', 'Token:'])
self.assertTrue(not stderr)
开发者ID:dani4571,项目名称:swiftly,代码行数:15,代码来源:test_auth.py
示例19: test_get_container_raw
def test_get_container_raw(self):
stdout = StringIO()
stderr = StringIO()
args = list(self.start_args)
args.extend(['get', self.container, '-r'])
cli = CLI(args=args, stdout=stdout, stderr=stderr)
rv = cli.main()
self.assertEquals(rv, 0)
stdout = json.loads(stdout.getvalue())
self.assertEquals(len(stdout), 1)
stdout = stdout[0]
self.assertEquals(stdout['bytes'], 9)
self.assertEquals(stdout['hash'], 'e9de89b0a5e9ad6efd5e5ab543ec617c')
self.assertEquals(stdout['content_type'], 'application/octet-stream')
self.assertEquals(stdout['name'], 'test')
self.assertEquals(stderr.getvalue(), '')
开发者ID:dani4571,项目名称:swiftly,代码行数:16,代码来源:test_get.py
示例20: test_get_container_raw
def test_get_container_raw(self):
stdout = StringIO()
stderr = StringIO()
args = list(self.start_args)
args.extend(["get", self.container, "-r"])
cli = CLI(args=args, stdout=stdout, stderr=stderr)
rv = cli.main()
self.assertEquals(rv, 0)
stdout = json.loads(stdout.getvalue())
self.assertEquals(len(stdout), 1)
stdout = stdout[0]
self.assertEquals(stdout["bytes"], 9)
self.assertEquals(stdout["hash"], "e9de89b0a5e9ad6efd5e5ab543ec617c")
self.assertEquals(stdout["content_type"], "application/octet-stream")
self.assertEquals(stdout["name"], "test")
self.assertEquals(stderr.getvalue(), "")
开发者ID:rgbkrk,项目名称:swiftly,代码行数:16,代码来源:test_get.py
注:本文中的swiftly.cli.CLI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论