예제 #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
파일: __init__.py 프로젝트: amancevice/furi
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()