Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
Archivo: test_s3.py Proyecto: 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())
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
Archivo: test_s3.py Proyecto: 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()
Ejemplo n.º 7
0
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()
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 11
0
def test_dispatch_local_no_scheme():
    returned = type(furi.open('/abs/path/test'))
    expected = furi.File
    assert_equal(returned, expected)
Ejemplo n.º 12
0
def test_bad_scheme():
    furi.open('foo://bar/path/test')
Ejemplo n.º 13
0
def test_dispatch_sftp():
    returned = type(furi.open('sftp://*****:*****@host/path/test'))
    expected = furi.SftpFile
    assert_equal(returned, expected)
Ejemplo n.º 14
0
def test_dispatch_s3():
    returned = type(furi.open('s3://bucket/path/to/test'))
    expected = furi.S3File
    assert_equal(returned, expected)
Ejemplo n.º 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)
Ejemplo n.º 16
0
def test_bad_mode():
    furi.open("foo.txt", mode="j")
Ejemplo n.º 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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
def test_repr():
    furifile = furi.open("/path/to/file")
    returned = repr(furifile)
    expected = "<File: /path/to/file>"
    assert_equal(returned, expected)
Ejemplo n.º 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)
Ejemplo n.º 21
0
def test_cant_stream():
    furi.open("/path/to/file").stream()
Ejemplo n.º 22
0
def test_file_exists():
    furifile = furi.open(__file__)
    assert furifile.exists()
Ejemplo n.º 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)
Ejemplo n.º 24
0
def test_not_file_exists():
    furifile = furi.open('/foo/bar/fizz/buzz')
    assert not furifile.exists()
Ejemplo n.º 25
0
Archivo: test_s3.py Proyecto: 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()
Ejemplo n.º 26
0
def test_dispatch_local_with_scheme():
    returned = type(furi.open('file:///abs/path/test'))
    expected = furi.furifile.File
    assert_equal(returned, expected)
Ejemplo n.º 27
0
Archivo: test_s3.py Proyecto: 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)
Ejemplo n.º 28
0
def test_exists():
    furifile = furi.open(__file__)
    assert furifile.exists()
Ejemplo n.º 29
0
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()
Ejemplo n.º 30
0
def test_not_exists():
    furifile = furi.open('/foo/bar/fizz/buzz')
    assert not furifile.exists()
Ejemplo n.º 31
0
def test_connect():
    s3furi = furi.open('s3://bucket/path/file')
    returned = s3furi.connect()
    expected = boto.s3.connection.S3Connection
    assert_is_instance(returned, expected)
Ejemplo n.º 32
0
def test_not_exists():
    furifile = furi.open("/foo/bar/fizz/buzz")
    assert not furifile.exists()