Exemplo n.º 1
0
def test_exportdb_single_rec(tmpdir):
    with NamedTemporaryFile(delete=False) as f:
        db = BukuDb(dbfile=f.name)
        db.add_rec('http://example.com')
        exp_file = tmpdir.join('export')
        db.exportdb(exp_file.strpath)
        with open(exp_file.strpath) as f:
            assert f.read()
Exemplo n.º 2
0
def test_exportdb_single_rec(tmpdir):
    with NamedTemporaryFile(delete=False) as f:
        db = BukuDb(dbfile=f.name)
        db.add_rec("http://example.com")
        exp_file = tmpdir.join("export")
        db.exportdb(exp_file.strpath)
        with open(exp_file.strpath, encoding="utf8", errors="surrogateescape") as f:
            assert f.read()
Exemplo n.º 3
0
def test_exportdb_to_db():
    with NamedTemporaryFile(delete=False) as f1, NamedTemporaryFile(
            delete=False, suffix='.db') as f2:
        db = BukuDb(dbfile=f1.name)
        db.add_rec('http://example.com')
        db.add_rec('http://google.com')
        with mock.patch('builtins.input', return_value='y'):
            db.exportdb(f2.name)
        db2 = BukuDb(dbfile=f2.name)
        assert db.get_rec_all() == db2.get_rec_all()
Exemplo n.º 4
0
def test_exportdb_empty_db():
    with NamedTemporaryFile(delete=False) as f:
        db = BukuDb(dbfile=f.name)
        with NamedTemporaryFile(delete=False) as f2:
            res = db.exportdb(f2.name)
            assert not res