From ae66ada99ccf5561280fc1d3a6eda1e7e6759864 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 31 Jan 2020 10:42:55 -0600 Subject: [PATCH] Stop using bsddb in tests --- gramps/gen/utils/test/file_test.py | 2 +- gramps/gui/editors/test/editreference_test.py | 6 +- .../plugins/test/db_undo_and_signals_test.py | 2 +- gramps/plugins/test/exports_test.py | 62 ------------------- gramps/plugins/test/imports_test.py | 4 +- gramps/plugins/test/tools_test.py | 2 +- 6 files changed, 8 insertions(+), 70 deletions(-) diff --git a/gramps/gen/utils/test/file_test.py b/gramps/gen/utils/test/file_test.py index 7f34ef10e..de442fdfc 100644 --- a/gramps/gen/utils/test/file_test.py +++ b/gramps/gen/utils/test/file_test.py @@ -58,7 +58,7 @@ class FileTest(unittest.TestCase): """ # Create database - db = make_database("bsddb") + db = make_database("sqlite") path = get_empty_tempdir("utils_file_test") db.load(path) diff --git a/gramps/gui/editors/test/editreference_test.py b/gramps/gui/editors/test/editreference_test.py index c96f51161..fe799857c 100644 --- a/gramps/gui/editors/test/editreference_test.py +++ b/gramps/gui/editors/test/editreference_test.py @@ -37,6 +37,7 @@ from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation, from gramps.cli.user import User from gramps.gen.dbstate import DbState from gramps.gen.db.utils import make_database +from gramps.gen.db import DbTxn from gramps.gui.editors.editreference import EditReference class MockWindow: @@ -56,7 +57,7 @@ class TestEditReference(unittest.TestCase): @unittest.skipUnless(MOCKING, "Requires unittest.mock to run") def test_editreference(self): dbstate = DbState() - db = make_database("bsddb") + db = make_database("sqlite") path = "/tmp/edit_ref_test" try: os.mkdir(path) @@ -66,7 +67,8 @@ class TestEditReference(unittest.TestCase): dbstate.change_database(db) source = Place() source.gramps_id = "P0001" - dbstate.db.place_map[source.handle] = source.serialize() + with DbTxn("test place", dbstate.db) as trans: + dbstate.db.add_place(source, trans) editor = MockEditReference(dbstate, uistate=None, track=[], source=source, source_ref=None, update=None) with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED: diff --git a/gramps/plugins/test/db_undo_and_signals_test.py b/gramps/plugins/test/db_undo_and_signals_test.py index 812d3d29f..bddd9461b 100644 --- a/gramps/plugins/test/db_undo_and_signals_test.py +++ b/gramps/plugins/test/db_undo_and_signals_test.py @@ -361,7 +361,7 @@ class DbTestClassBase(object): msg="Callback Manager disconnect cb check") -params = [('BsdDb', 'bsddb'), ('SQLite', 'sqlite')] +params = [('SQLite', 'sqlite')] for name, param in params: cls_name = "TestMyTestClass_%s" % (name, ) diff --git a/gramps/plugins/test/exports_test.py b/gramps/plugins/test/exports_test.py index 0a5cc39d7..587b1e1ba 100644 --- a/gramps/plugins/test/exports_test.py +++ b/gramps/plugins/test/exports_test.py @@ -207,16 +207,6 @@ class ExportControl(unittest.TestCase): call("-y", "-q", "--remove", TREE_NAME) def test_csv(self): - """ Run a csv export test """ - set_format(0) # Use ISO date for test - config.set('database.backend', 'bsddb') - src_file = 'exp_sample_csv.gramps' - tst_file = 'exp_sample_csv.csv' - msg = do_it(src_file, tst_file) - if msg: - self.fail(tst_file + ': ' + msg) - - def test_csv_sq(self): """ Run a csv export test """ set_format(0) # Use ISO date for test config.set('database.backend', 'sqlite') @@ -227,16 +217,6 @@ class ExportControl(unittest.TestCase): self.fail(tst_file + ': ' + msg) def test_ged(self): - """ Run a Gedcom export test """ - config.set('preferences.place-auto', True) - config.set('database.backend', 'bsddb') - src_file = 'exp_sample.gramps' - tst_file = 'exp_sample_ged.ged' - msg = do_it(src_file, tst_file, gedfilt) - if msg: - self.fail(tst_file + ': ' + msg) - - def test_ged_sq(self): """ Run a Gedcom export test """ config.set('preferences.place-auto', True) config.set('database.backend', 'sqlite') @@ -247,16 +227,6 @@ class ExportControl(unittest.TestCase): self.fail(tst_file + ': ' + msg) def test_vcard(self): - """ Run a vcard export test """ - config.set('preferences.place-auto', True) - config.set('database.backend', 'bsddb') - src_file = 'exp_sample.gramps' - tst_file = 'exp_sample.vcf' - msg = do_it(src_file, tst_file, vcffilt) - if msg: - self.fail(tst_file + ': ' + msg) - - def test_vcard_sq(self): """ Run a vcard export test """ config.set('preferences.place-auto', True) config.set('database.backend', 'sqlite') @@ -268,17 +238,6 @@ class ExportControl(unittest.TestCase): @patch('gramps.plugins.export.exportvcalendar.time.localtime', mock_localtime) def test_vcs(self): - """ Run a Vcalandar export test """ - config.set('preferences.place-auto', True) - config.set('database.backend', 'bsddb') - src_file = 'exp_sample.gramps' - tst_file = 'exp_sample.vcs' - msg = do_it(src_file, tst_file) - if msg: - self.fail(tst_file + ': ' + msg) - - @patch('gramps.plugins.export.exportvcalendar.time.localtime', mock_localtime) - def test_vcs_sq(self): """ Run a Vcalandar export test """ config.set('preferences.place-auto', True) config.set('database.backend', 'sqlite') @@ -289,16 +248,6 @@ class ExportControl(unittest.TestCase): self.fail(tst_file + ': ' + msg) def test_gw(self): - """ Run a Geneweb export test """ - config.set('preferences.place-auto', True) - config.set('database.backend', 'bsddb') - src_file = 'exp_sample.gramps' - tst_file = 'exp_sample.gw' - msg = do_it(src_file, tst_file) - if msg: - self.fail(tst_file + ': ' + msg) - - def test_gw_sq(self): """ Run a Geneweb export test """ config.set('preferences.place-auto', True) config.set('database.backend', 'sqlite') @@ -309,17 +258,6 @@ class ExportControl(unittest.TestCase): self.fail(tst_file + ': ' + msg) def test_wft(self): - """ Run a Web Family Tree export test """ - set_format(0) # Use ISO date for test - config.set('preferences.place-auto', True) - config.set('database.backend', 'bsddb') - src_file = 'exp_sample.gramps' - tst_file = 'exp_sample.wft' - msg = do_it(src_file, tst_file) - if msg: - self.fail(tst_file + ': ' + msg) - - def test_wft_sq(self): """ Run a Web Family Tree export test """ set_format(0) # Use ISO date for test config.set('preferences.place-auto', True) diff --git a/gramps/plugins/test/imports_test.py b/gramps/plugins/test/imports_test.py index dcf613ea2..6e69edc8d 100644 --- a/gramps/plugins/test/imports_test.py +++ b/gramps/plugins/test/imports_test.py @@ -199,18 +199,16 @@ def make_tst_function(tstfile, file_name): """ @patch('gramps.plugins.db.dbapi.dbapi.time') - @patch('gramps.plugins.db.bsddb.write.time') @patch('gramps.gen.utils.unknown.localtime') @patch('gramps.gen.utils.unknown.time') @patch('time.localtime') - def tst(self, mockptime, mocktime, mockltime, mockwtime, mockdtime): + def tst(self, mockptime, mocktime, mockltime, mockdtime): """ This compares the import file with the expected result '.gramps' file. """ mockptime.side_effect = mock_localtime mocktime.side_effect = mock_time mockltime.side_effect = mock_localtime - mockwtime.side_effect = mock_time mockdtime.side_effect = mock_time fn1 = os.path.join(TEST_DIR, tstfile) fn2 = os.path.join(TEST_DIR, (file_name + ".gramps")) diff --git a/gramps/plugins/test/tools_test.py b/gramps/plugins/test/tools_test.py index a861071c5..596296d41 100644 --- a/gramps/plugins/test/tools_test.py +++ b/gramps/plugins/test/tools_test.py @@ -77,7 +77,7 @@ class ToolControl(unittest.TestCase): """ def setUp(self): self.db_backend = config.get('database.backend') - call("--config=database.backend:bsddb", "-y", "-q", "--remove", TREE_NAME) + call("--config=database.backend:sqlite", "-y", "-q", "--remove", TREE_NAME) def tearDown(self): config.set('database.backend', self.db_backend)