示例#1
0
文件: test_s3.py 项目: sleibman/furi
def test_write_stream():
    value = "Hello, world!\n\nGoodby, cruel world."
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')

    s3furi1 = furi.open('s3://furi/foo/bar/bizz/buzz', mode='w')
    s3furi1.write(value)
    s3furi2 = furi.open('s3://furi/foo/bar/bizz/fizz', mode='w')
    s3furi2.write(s3furi1.stream())

    assert_equal(s3furi1.read(), s3furi2.read())
示例#2
0
文件: test_s3.py 项目: rhcm/furi
def test_write_stream():
    value = "Hello, world!\n\nGoodby, cruel world."
    ms3   = boto.connect_s3()
    bkt   = ms3.create_bucket('furi')

    s3furi1 = furi.open('s3://furi/foo/bar/bizz/buzz', mode='w')
    s3furi1.write(value)
    s3furi2 = furi.open('s3://furi/foo/bar/bizz/fizz', mode='w')
    s3furi2.write(s3furi1.stream())

    assert_equal(s3furi1.read(), s3furi2.read())
示例#3
0
def test_write():
    value = "Hello, world!\n\nGoodby, cruel world."
    with tempfile.NamedTemporaryFile() as tmp:
        furifile = furi.open(tmp.name, mode='w+')
        furifile.write(value)
        furifile.stream().seek(0)
        assert_equal(furifile.read(), value)
示例#4
0
def test_write():
    value = "Hello, world!\n\nGoodbye, cruel world."
    with tempfile.NamedTemporaryFile() as tmp:
        furifile = furi.open(tmp.name, mode='w+')
        furifile.write(value)
        furifile.stream().seek(0)
        assert_equal(furifile.read(), value)
示例#5
0
def test_stream_resets():
    with open(__file__, 'r') as this:
        furifile = furi.open(__file__)
        stream = furifile.stream()
        stream.read()
        returned = furifile.read()
        expected = this.read()
        assert_equal(returned, expected)
示例#6
0
文件: test_s3.py 项目: rhcm/furi
def test_exists():
    value = "Hello, world!\n\nGoodby, cruel world."
    ms3   = boto.connect_s3()
    bkt   = ms3.create_bucket('furi')
    key   = boto.s3.key.Key(bkt, 'foo/bar/bizz/buzz')
    key.set_contents_from_string(value)

    s3furi = furi.open('s3://furi/foo/bar/bizz/buzz')
    assert s3furi.exists()
示例#7
0
文件: test_s3.py 项目: sleibman/furi
def test_exists():
    value = "Hello, world!\n\nGoodby, cruel world."
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')
    key = boto.s3.key.Key(bkt, 'foo/bar/bizz/buzz')
    key.set_contents_from_string(value)

    s3furi = furi.open('s3://furi/foo/bar/bizz/buzz')
    assert s3furi.exists()
示例#8
0
def test_s3_read_stream():
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')
    key = boto.s3.key.Key(bkt)
    key.name = 'foo/bar/bizz/buzz'
    value = "Hello, world!\n\nGoodbye, cruel world.".encode("utf-8")
    key.set_contents_from_string(value)

    with furi.open('s3://furi/foo/bar/bizz/buzz', mode='w') as s3furi:
        assert_equal(s3furi.read(), value)
示例#9
0
def test_s3_stream():
    value = "Hello, world!\n\nGoodbye, cruel world."
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')
    key = boto.s3.key.Key(bkt, 'foo/bar/bizz/buzz')
    key.set_contents_from_string(value)

    with furi.open('s3://furi/foo/bar/bizz/buzz') as tmp:
        tmp.stream()
        tmp.stream()
示例#10
0
def test_iter():
    lines = [
        "This is line 1\n",
        "This is line 2\n"]
    with tempfile.NamedTemporaryFile() as tmp:
        for line in lines:
            tmp.write(line.encode("utf8"))
        tmp.flush()
        furifile = furi.open(tmp.name)
        returned = list(iter(furifile))
    assert_equal(returned, lines)
示例#11
0
文件: __init__.py 项目: sleibman/furi
def test_dispatch_local_no_scheme():
    returned = type(furi.open('/abs/path/test'))
    expected = furi.File
    assert_equal(returned, expected)
示例#12
0
文件: __init__.py 项目: sleibman/furi
def test_bad_scheme():
    furi.open('foo://bar/path/test')
示例#13
0
文件: __init__.py 项目: sleibman/furi
def test_dispatch_sftp():
    returned = type(furi.open('sftp://*****:*****@host/path/test'))
    expected = furi.SftpFile
    assert_equal(returned, expected)
示例#14
0
文件: __init__.py 项目: sleibman/furi
def test_dispatch_s3():
    returned = type(furi.open('s3://bucket/path/to/test'))
    expected = furi.S3File
    assert_equal(returned, expected)
示例#15
0
def test_matches():
    pattern = re.compile('[A-Z][a-z]+\.[Yy][Aa]?[Mm][Ll]')
    furifile = furi.open('/abs/path/to/Hello.yml')
    assert furifile.matches(pattern)
示例#16
0
def test_bad_mode():
    furi.open("foo.txt", mode="j")
示例#17
0
def test_read():
    with open(__file__, 'r') as this:
        furifile = furi.open(__file__)
        returned = furifile.read()
        expected = this.read()
        assert_equal(returned, expected)
示例#18
0
文件: test_base.py 项目: rhcm/furi
def test_matches():
    pattern = re.compile("[A-Z][a-z]+\.[Yy][Aa]?[Mm][Ll]")
    furifile = furi.open("/abs/path/to/Hello.yml")
    assert furifile.matches(pattern)
示例#19
0
def test_repr():
    furifile = furi.open("/path/to/file")
    returned = repr(furifile)
    expected = "<File: /path/to/file>"
    assert_equal(returned, expected)
示例#20
0
def test_not_matches():
    pattern = re.compile('[A-Z][a-z]+\.[Yy][Aa]?[Mm][Ll]')
    furifile = furi.open('/abs/path/to/Hello.txt')
    assert not furifile.matches(pattern)
示例#21
0
def test_cant_stream():
    furi.open("/path/to/file").stream()
示例#22
0
def test_file_exists():
    furifile = furi.open(__file__)
    assert furifile.exists()
示例#23
0
def test_read():
    with open(__file__, 'r') as this:
        furifile = furi.open(__file__)
        returned = furifile.read()
        expected = this.read()
        assert_equal(returned, expected)
示例#24
0
def test_not_file_exists():
    furifile = furi.open('/foo/bar/fizz/buzz')
    assert not furifile.exists()
示例#25
0
文件: test_s3.py 项目: rhcm/furi
def test_not_exists():
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')

    s3furi = furi.open('s3://furi/foo/bar/bizz/buzz')
    assert not s3furi.exists()
示例#26
0
def test_dispatch_local_with_scheme():
    returned = type(furi.open('file:///abs/path/test'))
    expected = furi.furifile.File
    assert_equal(returned, expected)
示例#27
0
文件: test_s3.py 项目: rhcm/furi
def test_connect():
    s3furi = furi.open('s3://bucket/path/file')
    returned = s3furi.connect()
    expected = boto.s3.connection.S3Connection
    assert_is_instance(returned, expected)
示例#28
0
def test_exists():
    furifile = furi.open(__file__)
    assert furifile.exists()
示例#29
0
文件: test_s3.py 项目: sleibman/furi
def test_not_exists():
    ms3 = boto.connect_s3()
    bkt = ms3.create_bucket('furi')

    s3furi = furi.open('s3://furi/foo/bar/bizz/buzz')
    assert not s3furi.exists()
示例#30
0
def test_not_exists():
    furifile = furi.open('/foo/bar/fizz/buzz')
    assert not furifile.exists()
示例#31
0
文件: test_s3.py 项目: sleibman/furi
def test_connect():
    s3furi = furi.open('s3://bucket/path/file')
    returned = s3furi.connect()
    expected = boto.s3.connection.S3Connection
    assert_is_instance(returned, expected)
示例#32
0
文件: test_base.py 项目: rhcm/furi
def test_not_exists():
    furifile = furi.open("/foo/bar/fizz/buzz")
    assert not furifile.exists()