Exemple #1
0
def test_drop():
    with tmpfile('.bson') as fn:
        bs = BSON(fn)
        append(bs, dat)

        assert os.path.exists(fn)
        drop(bs)
        assert not os.path.exists(fn)
Exemple #2
0
def test_read_gzip():
    with tmpfile('.bson.gz') as fn:
        f = gzip.open(fn, 'wb')
        for item in dat:
            f.write(bson.BSON.encode(item))
        f.close()
        b = BSON(fn)
        assert convert(list, b) == dat
Exemple #3
0
def test_missing_to_csv():
    data = [dict(a=1, b=2), dict(a=2, c=4)]
    with tmpfile('.bson') as fn:
        bs = BSON(fn)
        bs = odo(data, bs)

        with tmpfile('.csv') as csvf:
            csv = odo(bs, csvf)
            with open(csv.path, 'rt') as f:
                result = f.read()

    expected = 'a,b,c\n1,2.0,\n2,,4.0\n'
    assert result == expected
Exemple #4
0
def test_convert_bson_list():
    with bson_file(dat) as fn:
        b = BSON(fn)
        assert convert(list, b) == dat
Exemple #5
0
def test_append_bson():
    with tmpfile('.bson') as fn:
        b = BSON(fn)
        append(b, dat)
        assert convert(list, b) == dat
Exemple #6
0
def test_discover_bson():
    with bson_file(dat) as fn:
        b = BSON(fn)
        assert discover(b) == discover(dat)
Exemple #7
0
def test_write_gzip():
    with tmpfile('.bson.gz') as fn:
        b = BSON(fn)
        append(b, dat)

        assert convert(list, b) == dat