diff --git a/tests/test_bukuDb.py b/tests/test_bukuDb.py index 2e33b3d..2d70eef 100644 --- a/tests/test_bukuDb.py +++ b/tests/test_bukuDb.py @@ -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