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


Python radula.RadulaProxy类代码示例

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


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

示例1: compare_acl

def compare_acl(test_set):
    acl, subject, expected, unexpected = test_set
    conn = boto.connect_s3()
    proxy = RadulaProxy(connection=conn)
    radu = Radula(connection=conn)
    bucket = conn.create_bucket(TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": REMOTE_FILE
    })
    proxy.upload(**args)
    # for sake of testing, ensure equality
    key_name = os.path.basename(REMOTE_FILE)
    key = bucket.get_key(key_name)
    key.set_canned_acl(acl)

    args = vars(_parse_args(['compare-acl', subject, acl]))
    radu.compare_acl(**args)
    out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
    sys.stdout.truncate(0)

    for msg in expected:
        errmsg = "Expecting log message containing '{0}'".format(msg)
        assert_in(msg, out, msg=errmsg)

    for msg in unexpected:
        errmsg = "Not expecting log message containing '{0}'".format(msg)
        assert_not_in(msg, out, msg=errmsg)
开发者ID:mikulely,项目名称:radula,代码行数:31,代码来源:user_test.py

示例2: allow_user

def allow_user(method, test_set):
    subject, flags, expected, unexpected = test_set

    conn = boto.connect_s3()
    proxy = RadulaProxy(connection=conn)
    radu = Radula(connection=conn)
    proxy.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": subject
    })
    proxy.upload(**args)
    sys.stdout.truncate(0)

    flags = flags.split(' ')
    args = [arg for arg in flags + [method, ALT_USER, subject] if arg]
    args = vars(_parse_args(args))
    getattr(radu, args.get("command").replace('-', '_'))(**args)
    out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
    sys.stdout.truncate(0)

    for msg in expected:
        errmsg = "Expecting log message containing '{0}'".format(msg)
        assert_in(msg, out, msg=errmsg)

    for msg in unexpected:
        errmsg = "Not expecting log message containing '{0}'".format(msg)
        assert_not_in(msg, out, msg=errmsg)
开发者ID:mikulely,项目名称:radula,代码行数:31,代码来源:user_test.py

示例3: set_acl_subject

def set_acl_subject(test_set, acl):
    subject, expected, unexpected = test_set
    conn = boto.connect_s3()
    proxy = RadulaProxy(connection=conn)
    radu = Radula(connection=conn)
    proxy.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": subject
    })
    proxy.upload(**args)
    sys.stdout.truncate(0)

    args = vars(_parse_args(['set-acl', subject, acl]))
    radu.set_acl(**args)
    out = [line.strip() for line in sys.stdout.getvalue().split("\n")]
    sys.stdout.truncate(0)

    for msg in expected:
        errmsg = "Expecting log message containing '{0}'".format(msg)
        assert_in(msg, out, msg=errmsg)

    for msg in unexpected:
        errmsg = "Not expecting log message containing '{0}'".format(msg)
        assert_not_in(msg, out, msg=errmsg)
开发者ID:mikulely,项目名称:radula,代码行数:28,代码来源:user_test.py

示例4: dl_method

def dl_method(method, test_set):
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": REMOTE_FILE
    })
    radu.upload(**args)
    sys.stdout.truncate(0)

    args = vars(_parse_args([method, '-f']))
    args.update(test_set)
    getattr(radu, method)(**args)

    out = sys.stdout.getvalue().strip()
    msgs = [
        "Download Progress",
        "100.00%",
    ]

    for msg in msgs:
        assert_in(msg, out, msg="Expecting log message containing '{0}'".format(msg))
    target = test_set.get("target", TEST_FILE)
    assert_true(os.path.isfile(target))
    if target != TEST_FILE:
        os.remove(target)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:29,代码来源:proxy_test.py

示例5: local_md5_threads_test

def local_md5_threads_test():
    radu = RadulaProxy(connection=boto.connect_s3())
    args = vars(_parse_args(["local-md5"]))
    args.update({
        "subject": 'test_file_not_found__intentional'
    })
    radu.local_md5(**args)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:7,代码来源:proxy_test.py

示例6: up_method_fail

def up_method_fail(method, test_set):
    radu = RadulaProxy(connection=boto.connect_s3())
    bucket = TEST_BUCKET
    radu.make_bucket(subject=bucket)
    sys.stdout.truncate(0)

    getattr(radu, method)(**test_set)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:7,代码来源:proxy_test.py

示例7: up_method

def up_method(method, test_set):
    handler = TestHandler(Matcher())
    logger = logging.getLogger()
    logger.addHandler(handler)

    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)
    sys.stdout.truncate(0)

    args = vars(_parse_args(["-y", method]))
    args.update(test_set)
    getattr(radu, args.get("command"))(**args)

    assert_false(handler.matches(levelno=logging.ERROR))
    assert_false(handler.matches(levelno=logging.WARNING))
    assert_true(handler.matches(levelno=logging.INFO))
    msgs = [
        "uploading",
        "tests.s3.amazonaws.com/data.txt",
        "Checksum Verified!"
    ]

    fmt = "Expecting log message containing '{0}'"
    for msg in msgs:
        assert_true(
            handler.matches(message=msg),
            msg=fmt.format(msg)
        )
开发者ID:bibby,项目名称:radula,代码行数:28,代码来源:proxy_test.py

示例8: list_method

def list_method(method, buckets):
    radu = RadulaProxy(connection=boto.connect_s3())
    for bucket in buckets:
        radu.make_bucket(subject=bucket)
    sys.stdout.truncate(0)

    getattr(radu, method)()
    out = sys.stdout.getvalue().strip()
    assert_equal(sorted(buckets), sorted([b for b in out.split("\n") if b]))
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:9,代码来源:proxy_test.py

示例9: bucket_info_test

def bucket_info_test():
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)
    sys.stdout.truncate(0)
    radu.info(subject=TEST_BUCKET)
    out = sys.stdout.getvalue().strip()
    info = json.loads(out)
    for k in ('keys', 'size_human', 'size'):
        assert_in(k, info)
    key_info = info.get("keys")
    for k in ('count', 'largest', 'newest', 'oldest'):
        assert_in(k, key_info)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:12,代码来源:proxy_test.py

示例10: remote_md5_fail_test

def remote_md5_fail_test():
    # ensure original text
    with open(TEST_FILE, 'w') as test_file:
        test_file.write("data")
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)
    sys.stdout.truncate(0)

    # 'threads' needed
    args = vars(_parse_args(["remote-md5", "-t", "2"]))
    args.update({
        "subject": os.path.join(TEST_BUCKET, 'test_file_not_found__intentional')
    })
    radu.remote_md5(**args)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:14,代码来源:proxy_test.py

示例11: dl_method_fail

def dl_method_fail(method, test_set):
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": REMOTE_FILE
    })
    radu.upload(**args)
    sys.stdout.truncate(0)

    getattr(radu, method)(**test_set)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:14,代码来源:proxy_test.py

示例12: set_acl_canned_fail

def set_acl_canned_fail(acl):
    conn = boto.connect_s3()
    proxy = RadulaProxy(connection=conn)
    radu = Radula(connection=conn)
    proxy.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": REMOTE_FILE
    })
    proxy.upload(**args)
    sys.stdout.truncate(0)

    args = vars(_parse_args(['set-acl', REMOTE_FILE, acl]))
    radu.set_acl(**args)
开发者ID:mikulely,项目名称:radula,代码行数:17,代码来源:user_test.py

示例13: rm_method

def rm_method(method):
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)

    # give something to rm
    args = vars(_parse_args(['up']))
    expected = []
    for i in xrange(3):
        remote_file = REMOTE_FILE + str(i)
        expected.append(remote_file)
        args.update({
            "subject": TEST_FILE,
            "target": remote_file
        })
        radu.upload(**args)

    while len(expected):
        remove_file = expected.pop()
        sys.stdout.truncate(0)
        getattr(radu, method)(subject=remove_file)

        radu.keys(subject=TEST_BUCKET)
        keys = [k.strip() for k in sys.stdout.getvalue().strip().split("\n")]

        absent_key = os.path.basename(remove_file)
        assert_not_in(absent_key, keys, msg="Expecting absence of key mention '{0}'".format(absent_key))
        for expected_key in expected:
            expected_key = os.path.basename(expected_key)
            assert_in(expected_key, keys, msg="Expecting output containing '{0}'".format(expected_key))
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:29,代码来源:proxy_test.py

示例14: copy_method

def copy_method(method):
    handler = TestHandler(Matcher())
    logger = logging.getLogger()
    logger.addHandler(handler)
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)

    # give something to download
    args = vars(_parse_args(['up']))
    args.update({
        "subject": TEST_FILE,
        "target": REMOTE_FILE
    })
    radu.upload(**args)
    sys.stdout.truncate(0)

    # 'threads' needed
    args = vars(_parse_args(['-y', method]))
    target_file = REMOTE_FILE + '-copy'
    args.update({
        "subject": REMOTE_FILE,
        "target": target_file
    })
    radu.streaming_copy(**args)

    msgs = [
        "Finished uploading",
        "tests.s3.amazonaws.com/data.txt",
        "Download URL",
        "Key data matches!"
    ]

    for msg in msgs:
        fmt = "Expecting log message containing '{0}'"
        assert_true(handler.matches(message=msg), msg=fmt.format(msg))

    radu.keys(subject=TEST_BUCKET)
    keys = [k.strip() for k in sys.stdout.getvalue().strip().split("\n")]
    expected = [REMOTE_FILE, target_file]

    fmt = "Expecting output containing '{0}'"
    for expected_key in expected:
        expected_key = os.path.basename(expected_key)
        assert_in(expected_key, keys, msg=fmt.format(expected_key))
开发者ID:bibby,项目名称:radula,代码行数:44,代码来源:proxy_test.py

示例15: key_info_test

def key_info_test():
    radu = RadulaProxy(connection=boto.connect_s3())
    radu.make_bucket(subject=TEST_BUCKET)

    # give something to info
    args = vars(_parse_args(['up']))
    remote_file = REMOTE_FILE
    args.update({
        "subject": TEST_FILE,
        "target": remote_file
    })
    radu.upload(**args)
    sys.stdout.truncate(0)
    radu.info(subject=REMOTE_FILE)

    out = sys.stdout.getvalue().strip()
    info = json.loads(out)
    for k in ('content_length', 'owner', 'size', 'bucket'):
        assert_in(k, info)
    assert_equal(info.get("bucket"), TEST_BUCKET)
开发者ID:magicrobotmonkey,项目名称:radula,代码行数:20,代码来源:proxy_test.py


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