Make copy of example.gramps to tests dir and point test modules to it

This commit is contained in:
prculley 2016-08-30 11:46:55 -05:00
parent 70404e1931
commit e3b482dd57
10 changed files with 65754 additions and 12 deletions

65712
data/tests/example.gramps Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,10 +22,12 @@
Unittest that tests event-specific filter rules Unittest that tests event-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.event import ( from gramps.gen.filters.rules.event import (
AllEvents, HasType, HasIdOf, HasGallery, RegExpIdOf, HasCitation, HasNote, AllEvents, HasType, HasIdOf, HasGallery, RegExpIdOf, HasCitation, HasNote,
@ -33,6 +35,8 @@ from gramps.gen.filters.rules.event import (
MatchesSourceConfidence, HasAttribute, HasData, ChangedSince, HasTag, MatchesSourceConfidence, HasAttribute, HasData, ChangedSince, HasTag,
HasDayOfWeek) HasDayOfWeek)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericEventFilter = GenericFilterFactory('Event') GenericEventFilter = GenericFilterFactory('Event')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -45,7 +49,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,10 +22,12 @@
Unittest that tests family-specific filter rules Unittest that tests family-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.family import ( from gramps.gen.filters.rules.family import (
AllFamilies, HasRelType, HasGallery, HasIdOf, HasLDS, HasNote, RegExpIdOf, AllFamilies, HasRelType, HasGallery, HasIdOf, HasLDS, HasNote, RegExpIdOf,
@ -35,6 +37,8 @@ from gramps.gen.filters.rules.family import (
MotherHasIdOf, ChildHasNameOf, ChildHasIdOf, ChangedSince, HasTag, MotherHasIdOf, ChildHasNameOf, ChildHasIdOf, ChangedSince, HasTag,
HasTwins, IsAncestorOf, IsDescendantOf) HasTwins, IsAncestorOf, IsDescendantOf)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericFamilyFilter = GenericFilterFactory('Family') GenericFamilyFilter = GenericFilterFactory('Family')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -47,7 +51,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,10 +22,12 @@
Unittest that tests media-specific filter rules Unittest that tests media-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.media import ( from gramps.gen.filters.rules.media import (
AllMedia, HasIdOf, RegExpIdOf, HasCitation, HasNoteRegexp, AllMedia, HasIdOf, RegExpIdOf, HasCitation, HasNoteRegexp,
@ -33,6 +35,8 @@ from gramps.gen.filters.rules.media import (
HasSourceOf, MediaPrivate, MatchesSourceConfidence, HasMedia, HasSourceOf, MediaPrivate, MatchesSourceConfidence, HasMedia,
HasAttribute, ChangedSince, HasTag) HasAttribute, ChangedSince, HasTag)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericMediaFilter = GenericFilterFactory('Media') GenericMediaFilter = GenericFilterFactory('Media')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -45,7 +49,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,15 +22,19 @@
Unittest that tests note-specific filter rules Unittest that tests note-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.note import ( from gramps.gen.filters.rules.note import (
AllNotes, HasIdOf, RegExpIdOf, HasNote, MatchesRegexpOf, AllNotes, HasIdOf, RegExpIdOf, HasNote, MatchesRegexpOf,
HasReferenceCountOf, NotePrivate, ChangedSince, HasTag, HasType) HasReferenceCountOf, NotePrivate, ChangedSince, HasTag, HasType)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericNoteFilter = GenericFilterFactory('Note') GenericNoteFilter = GenericFilterFactory('Note')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -43,7 +47,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,10 +22,12 @@
Unittest that tests person-specific filter rules Unittest that tests person-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilter from gramps.gen.filters import GenericFilter
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.person import ( from gramps.gen.filters.rules.person import (
Disconnected, Everyone, FamilyWithIncompleteEvent, HasAlternateName, Disconnected, Everyone, FamilyWithIncompleteEvent, HasAlternateName,
@ -36,6 +38,9 @@ from gramps.gen.filters.rules.person import (
NoDeathdate, PeoplePrivate, PeoplePublic, PersonWithIncompleteEvent, NoDeathdate, PeoplePrivate, PeoplePublic, PersonWithIncompleteEvent,
RelationshipPathBetweenBookmarks) RelationshipPathBetweenBookmarks)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
""" """
Person rule tests. Person rule tests.
@ -46,7 +51,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,10 +22,12 @@
Unittest that tests place-specific filter rules Unittest that tests place-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.place import ( from gramps.gen.filters.rules.place import (
AllPlaces, HasCitation, HasGallery, HasIdOf, RegExpIdOf, HasNote, AllPlaces, HasCitation, HasGallery, HasIdOf, RegExpIdOf, HasNote,
@ -33,6 +35,8 @@ from gramps.gen.filters.rules.place import (
PlacePrivate, MatchesSourceConfidence, HasData, HasNoLatOrLon, PlacePrivate, MatchesSourceConfidence, HasData, HasNoLatOrLon,
InLatLonNeighborhood, ChangedSince, HasTag, HasTitle, IsEnclosedBy) InLatLonNeighborhood, ChangedSince, HasTag, HasTitle, IsEnclosedBy)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericPlaceFilter = GenericFilterFactory('Place') GenericPlaceFilter = GenericFilterFactory('Place')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -45,7 +49,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -22,15 +22,19 @@
Unittest that tests repository-specific filter rules Unittest that tests repository-specific filter rules
""" """
import unittest import unittest
import os
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.filters import GenericFilterFactory from gramps.gen.filters import GenericFilterFactory
from gramps.gen.const import DATA_DIR
from gramps.gen.filters.rules.repository import ( from gramps.gen.filters.rules.repository import (
AllRepos, HasIdOf, RegExpIdOf, HasNoteRegexp, HasReferenceCountOf, AllRepos, HasIdOf, RegExpIdOf, HasNoteRegexp, HasReferenceCountOf,
RepoPrivate, ChangedSince, MatchesNameSubstringOf, HasTag) RepoPrivate, ChangedSince, MatchesNameSubstringOf, HasTag)
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
GenericRepositoryFilter = GenericFilterFactory('Repository') GenericRepositoryFilter = GenericFilterFactory('Repository')
class BaseTest(unittest.TestCase): class BaseTest(unittest.TestCase):
@ -43,7 +47,7 @@ class BaseTest(unittest.TestCase):
""" """
Import example database. Import example database.
""" """
cls.db = import_as_dict("example/gramps/example.gramps", User()) cls.db = import_as_dict(EXAMPLE, User())
def filter_with_rule(self, rule): def filter_with_rule(self, rule):
""" """

View File

@ -21,6 +21,7 @@
""" Unittest for to_struct, from_struct """ """ Unittest for to_struct, from_struct """
import unittest import unittest
import os
from .. import (Person, Family, Event, Source, Place, Citation, from .. import (Person, Family, Event, Source, Place, Citation,
Repository, Media, Note, Tag) Repository, Media, Note, Tag)
@ -28,6 +29,10 @@ from gramps.gen.lib.struct import Struct
from gramps.gen.merge.diff import import_as_dict from gramps.gen.merge.diff import import_as_dict
from gramps.cli.user import User from gramps.cli.user import User
from gramps.gen.merge.diff import * from gramps.gen.merge.diff import *
from gramps.gen.const import DATA_DIR
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
EXAMPLE = os.path.join(TEST_DIR, "example.gramps")
class BaseCheck: class BaseCheck:
def test_from_struct(self): def test_from_struct(self):
@ -108,7 +113,7 @@ def generate_case(obj):
#name = "test_create_%s_%s" % (obj.__class__.__name__, obj.handle) #name = "test_create_%s_%s" % (obj.__class__.__name__, obj.handle)
#setattr(DatabaseCheck, name, test2) #setattr(DatabaseCheck, name, test2)
db = import_as_dict("example/gramps/example.gramps", User()) db = import_as_dict(EXAMPLE, User())
for table in db.get_table_func(): for table in db.get_table_func():
for handle in db.get_table_func(table,"handles_func")(): for handle in db.get_table_func(table,"handles_func")():
obj = db.get_table_func(table,"handle_func")(handle) obj = db.get_table_func(table,"handle_func")(handle)

View File

@ -49,10 +49,6 @@ class MockEditReference(EditReference):
self.window = MockWindow() self.window = MockWindow()
super().__init__(dbstate, uistate, track, source, source_ref, update) super().__init__(dbstate, uistate, track, source, source_ref, update)
example = os.path.abspath(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
"../../../..",
"example/gramps/example.gramps"))
class TestEditReference(unittest.TestCase): class TestEditReference(unittest.TestCase):