bsddb: fixed unittests

This commit is contained in:
Doug Blank 2015-06-06 07:20:45 -04:00
parent b13c731aa5
commit 3f48a504d4
4 changed files with 16 additions and 9 deletions

View File

@ -56,16 +56,22 @@ example = os.path.abspath(
"example/gramps/example.gramps"))
class TestEditReference(unittest.TestCase):
def setUp(self):
self.db = DictionaryDb()
@unittest.skipUnless(MOCKING, "Requires unittest.mock to run")
def test_editreference(self):
dbstate = DbState()
dbstate.db = self.db
db = dbstate.make_database("bsddb")
path = "/tmp/edit_ref_test"
try:
os.mkdir(path)
except:
pass
db.write_version(path)
db.load(path)
dbstate.change_database(db)
source = Place()
source.gramps_id = "P0001"
self.db.place_map[source.handle] = source
dbstate.db.place_map[source.handle] = source.serialize()
editor = MockEditReference(dbstate, uistate=None, track=[],
source=source, source_ref=None, update=None)
with patch('gramps.gui.editors.editreference.ErrorDialog') as MockED:

View File

@ -21,8 +21,8 @@
import unittest
from .. import DbReadBase, DbWriteBase, DbBsddbRead, DbBsddb
from ...proxy.proxybase import ProxyDbBase
from ...proxy import LivingProxyDb
from gramps.gen.proxy.proxybase import ProxyDbBase
from gramps.gen.proxy import LivingProxyDb
class DbTest(unittest.TestCase):
READ_METHODS = [

View File

@ -22,8 +22,9 @@ import unittest
import tempfile
import shutil
from gramps.gen.db import DbBsddb, DbTxn
from .. import DbBsddb, DbTxn
from gramps.cli.clidbman import CLIDbManager
from gramps.gen.dbstate import DbState
from gramps.gen.lib import (Source, RepoRef, Citation, Repository, Person,
Family, Event, Place, MediaObject)
@ -37,7 +38,7 @@ class GrampsDbBaseTest(unittest.TestCase):
self._tmpdir = tempfile.mkdtemp()
self._db = DbBsddb()
dbman = CLIDbManager(None)
dbman = CLIDbManager(DbState())
self._filename, title = dbman.create_new_db_cli(title="Test")
self._db.load(self._filename, dummy_callback, "w")

View File

@ -23,7 +23,7 @@ import logging
import time
from .. import DbTxn
from ...lib import Person, Event, Source, Citation
from gramps.gen.lib import Person, Event, Source, Citation
logger = logging.getLogger('Gramps.GrampsDbBase_Test')