Replace dictionarydb with inmemorydb, a sqlite :memory: db

This commit is contained in:
Doug Blank 2016-04-16 23:47:29 -04:00
parent cd5905dfdb
commit a605bf451f
5 changed files with 14 additions and 8 deletions

View File

@ -45,7 +45,7 @@ before_script:
script:
# --exclude=TestUser because of older version of mock
# without configure_mock
- nosetests3 --nologcapture --with-coverage --cover-package=gramps --exclude=TestcaseGenerator --exclude=vcard --exclude=merge_ref_test --exclude=user_test gramps
- GRAMPS_RESOURCES=. nosetests3 --nologcapture --with-coverage --cover-package=gramps --exclude=TestcaseGenerator --exclude=vcard --exclude=merge_ref_test --exclude=user_test gramps
after_success:
- codecov

View File

@ -117,3 +117,10 @@ def open_database(database, force_unlock=False):
"""
from ..dbstate import DbState
return DbState().open_database(database, force_unlock)
def make_database(dbid):
"""
Shortcut for external uses of databases.
"""
from ..dbstate import DbState
return DbState().make_database(dbid)

View File

@ -22,7 +22,7 @@
import unittest
from gramps.plugins.database.dictionarydb import DictionaryDb
from gramps.gen.db import make_database
from ..import (Person, Surname, Name, NameType, Family, FamilyRelType,
Event, EventType, Source, Place, PlaceName, Citation, Date,
@ -36,7 +36,7 @@ from ..import (Person, Surname, Name, NameType, Family, FamilyRelType,
class FieldBaseTest(unittest.TestCase):
def setUp(self):
db = DictionaryDb()
db = make_database("inmemorydb")
db.load(None)
with db.get_transaction_class()("Test", db) as trans:
# Add some people:

View File

@ -28,7 +28,7 @@ from gramps.cli.user import User
from ..dbstate import DbState
from gramps.cli.grampscli import CLIManager
from ..plug import BasePluginManager
from gramps.plugins.database.dictionarydb import DictionaryDb
from gramps.gen.db import make_database
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
@ -84,11 +84,11 @@ def parse(string):
def import_as_dict(filename, user=None):
"""
Import the filename into a DictionaryDb and return it.
Import the filename into a InMemoryDB and return it.
"""
if user is None:
user = User()
db = DictionaryDb()
db = make_database("inmemorydb")
db.load(None)
db.set_feature("skip-import-additions", True)
dbstate = DbState()
@ -225,7 +225,7 @@ def diff_dbs(db1, db2, user=None):
def diff_db_to_file(old_db, filename, user=None):
if user is None:
user = User()
# First, get data as a DictionaryDb
# First, get data as a InMemoryDB
new_db = import_as_dict(filename, user, user)
if new_db is not None:
# Next get differences:

View File

@ -33,7 +33,6 @@ except:
from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
Repository, Media, Note, Tag)
from gramps.gen.merge.diff import DictionaryDb
from gramps.cli.user import User
from gramps.gen.dbstate import DbState
from gramps.gen.merge.diff import *