Stop using bsddb in tests
This commit is contained in:
parent
b52c118673
commit
ae66ada99c
@ -58,7 +58,7 @@ class FileTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Create database
|
# Create database
|
||||||
db = make_database("bsddb")
|
db = make_database("sqlite")
|
||||||
path = get_empty_tempdir("utils_file_test")
|
path = get_empty_tempdir("utils_file_test")
|
||||||
db.load(path)
|
db.load(path)
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
|
|||||||
from gramps.cli.user import User
|
from gramps.cli.user import User
|
||||||
from gramps.gen.dbstate import DbState
|
from gramps.gen.dbstate import DbState
|
||||||
from gramps.gen.db.utils import make_database
|
from gramps.gen.db.utils import make_database
|
||||||
|
from gramps.gen.db import DbTxn
|
||||||
from gramps.gui.editors.editreference import EditReference
|
from gramps.gui.editors.editreference import EditReference
|
||||||
|
|
||||||
class MockWindow:
|
class MockWindow:
|
||||||
@ -56,7 +57,7 @@ class TestEditReference(unittest.TestCase):
|
|||||||
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
|
||||||
def test_editreference(self):
|
def test_editreference(self):
|
||||||
dbstate = DbState()
|
dbstate = DbState()
|
||||||
db = make_database("bsddb")
|
db = make_database("sqlite")
|
||||||
path = "/tmp/edit_ref_test"
|
path = "/tmp/edit_ref_test"
|
||||||
try:
|
try:
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
@ -66,7 +67,8 @@ class TestEditReference(unittest.TestCase):
|
|||||||
dbstate.change_database(db)
|
dbstate.change_database(db)
|
||||||
source = Place()
|
source = Place()
|
||||||
source.gramps_id = "P0001"
|
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=[],
|
editor = MockEditReference(dbstate, uistate=None, track=[],
|
||||||
source=source, source_ref=None, update=None)
|
source=source, source_ref=None, update=None)
|
||||||
with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED:
|
with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED:
|
||||||
|
@ -361,7 +361,7 @@ class DbTestClassBase(object):
|
|||||||
msg="Callback Manager disconnect cb check")
|
msg="Callback Manager disconnect cb check")
|
||||||
|
|
||||||
|
|
||||||
params = [('BsdDb', 'bsddb'), ('SQLite', 'sqlite')]
|
params = [('SQLite', 'sqlite')]
|
||||||
|
|
||||||
for name, param in params:
|
for name, param in params:
|
||||||
cls_name = "TestMyTestClass_%s" % (name, )
|
cls_name = "TestMyTestClass_%s" % (name, )
|
||||||
|
@ -207,16 +207,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
call("-y", "-q", "--remove", TREE_NAME)
|
call("-y", "-q", "--remove", TREE_NAME)
|
||||||
|
|
||||||
def test_csv(self):
|
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 """
|
""" Run a csv export test """
|
||||||
set_format(0) # Use ISO date for test
|
set_format(0) # Use ISO date for test
|
||||||
config.set('database.backend', 'sqlite')
|
config.set('database.backend', 'sqlite')
|
||||||
@ -227,16 +217,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
self.fail(tst_file + ': ' + msg)
|
self.fail(tst_file + ': ' + msg)
|
||||||
|
|
||||||
def test_ged(self):
|
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 """
|
""" Run a Gedcom export test """
|
||||||
config.set('preferences.place-auto', True)
|
config.set('preferences.place-auto', True)
|
||||||
config.set('database.backend', 'sqlite')
|
config.set('database.backend', 'sqlite')
|
||||||
@ -247,16 +227,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
self.fail(tst_file + ': ' + msg)
|
self.fail(tst_file + ': ' + msg)
|
||||||
|
|
||||||
def test_vcard(self):
|
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 """
|
""" Run a vcard export test """
|
||||||
config.set('preferences.place-auto', True)
|
config.set('preferences.place-auto', True)
|
||||||
config.set('database.backend', 'sqlite')
|
config.set('database.backend', 'sqlite')
|
||||||
@ -268,17 +238,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
|
|
||||||
@patch('gramps.plugins.export.exportvcalendar.time.localtime', mock_localtime)
|
@patch('gramps.plugins.export.exportvcalendar.time.localtime', mock_localtime)
|
||||||
def test_vcs(self):
|
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 """
|
""" Run a Vcalandar export test """
|
||||||
config.set('preferences.place-auto', True)
|
config.set('preferences.place-auto', True)
|
||||||
config.set('database.backend', 'sqlite')
|
config.set('database.backend', 'sqlite')
|
||||||
@ -289,16 +248,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
self.fail(tst_file + ': ' + msg)
|
self.fail(tst_file + ': ' + msg)
|
||||||
|
|
||||||
def test_gw(self):
|
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 """
|
""" Run a Geneweb export test """
|
||||||
config.set('preferences.place-auto', True)
|
config.set('preferences.place-auto', True)
|
||||||
config.set('database.backend', 'sqlite')
|
config.set('database.backend', 'sqlite')
|
||||||
@ -309,17 +258,6 @@ class ExportControl(unittest.TestCase):
|
|||||||
self.fail(tst_file + ': ' + msg)
|
self.fail(tst_file + ': ' + msg)
|
||||||
|
|
||||||
def test_wft(self):
|
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 """
|
""" Run a Web Family Tree export test """
|
||||||
set_format(0) # Use ISO date for test
|
set_format(0) # Use ISO date for test
|
||||||
config.set('preferences.place-auto', True)
|
config.set('preferences.place-auto', True)
|
||||||
|
@ -199,18 +199,16 @@ def make_tst_function(tstfile, file_name):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@patch('gramps.plugins.db.dbapi.dbapi.time')
|
@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.localtime')
|
||||||
@patch('gramps.gen.utils.unknown.time')
|
@patch('gramps.gen.utils.unknown.time')
|
||||||
@patch('time.localtime')
|
@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'
|
""" This compares the import file with the expected result '.gramps'
|
||||||
file.
|
file.
|
||||||
"""
|
"""
|
||||||
mockptime.side_effect = mock_localtime
|
mockptime.side_effect = mock_localtime
|
||||||
mocktime.side_effect = mock_time
|
mocktime.side_effect = mock_time
|
||||||
mockltime.side_effect = mock_localtime
|
mockltime.side_effect = mock_localtime
|
||||||
mockwtime.side_effect = mock_time
|
|
||||||
mockdtime.side_effect = mock_time
|
mockdtime.side_effect = mock_time
|
||||||
fn1 = os.path.join(TEST_DIR, tstfile)
|
fn1 = os.path.join(TEST_DIR, tstfile)
|
||||||
fn2 = os.path.join(TEST_DIR, (file_name + ".gramps"))
|
fn2 = os.path.join(TEST_DIR, (file_name + ".gramps"))
|
||||||
|
@ -77,7 +77,7 @@ class ToolControl(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.db_backend = config.get('database.backend')
|
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):
|
def tearDown(self):
|
||||||
config.set('database.backend', self.db_backend)
|
config.set('database.backend', self.db_backend)
|
||||||
|
Loading…
Reference in New Issue
Block a user