new: dev: test export db simple case

This commit is contained in:
rachmadaniHaryono 2019-04-28 08:12:00 +08:00
parent 542952cd75
commit 43ba2a50f8

View File

@ -13,7 +13,7 @@ import urllib
import zipfile
from genericpath import exists
from itertools import product
from tempfile import TemporaryDirectory
from tempfile import TemporaryDirectory, NamedTemporaryFile
from unittest import mock
import unittest
@ -1417,6 +1417,24 @@ def test_exclude_results_from_search(search_results, exclude_results, exp_res):
assert exp_res == res
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
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) as f:
assert f.read()
# Helper functions for testcases