moved test directory, tweaked tests, and fixes

This commit is contained in:
prculley 2016-05-26 11:22:06 -05:00
parent 7646d41774
commit 8cda91a377
21 changed files with 39 additions and 28 deletions

View File

@ -21,24 +21,14 @@
1 NOTE @N0@
1 NOTE Inline 1
1 SOUR Inline Source 1
1 OBJE
2 FILE Inline1
2 FORM jpg
0 @N0@ NOTE
1 CONC XREF N0
0 @I01@ INDI
1 NAME Living01
1 SEX M
1 SOUR inline Source 2
1 OBJE
2 FILE Inline2
3 FORM jpg
0 @S1@ SOUR
1 TITL Source S1
0 @S01@ SOUR
1 TITL Source S01
0 @O1@ OBJE
1 FILE XREF1
0 @O1@ OBJE
1 FILE XREF2
0 TRLR

Binary file not shown.

View File

@ -272,4 +272,3 @@
1 CHIL @134I@
1 CHIL @179I@
0 TRLR

View File

@ -0,0 +1,17 @@
Mismatch on file: test_FTM_CONC.ged
Source: S0029 handle=0000000500000005
Diff on: Source, pubinfo
<class 'str'>73: Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date:2009;
<class 'str'>74: Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date: 2009;
Citation: C0000 handle=0000000600000006
Diff on: Citation, page
<class 'str'>102: Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll:M432_394; Page: 435B; Image: 248
<class 'str'>103: Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248
Note: N0000 handle=0000000200000002
Diff on: Note, text, string
<class 'str'>54: The FTM way to do a CONC line with space at end --><--
<class 'str'>55: The FTM way to do a CONC line with space at end --> <--
Note: N0002 handle=0000000400000004
Diff on: Note, text, string
<class 'str'>136: Be nice if we supported FTM way to do CONC sousers would not have to spell check and edit their whole database for these kind of errors.
<class 'str'>137: Be nice if we supported FTM way to do CONC so users would not have to spell check and edit their whole database for these kind of errors.

View File

@ -1,5 +1,5 @@
Mismatch on file: vcard.vcf
Person: I0019
Person: I0019 handle=0000001800000018
Diff on: Person, primary_name, surname list #2, primary
<class 'bool'>: True
<class 'bool'>: False

View File

@ -10,7 +10,7 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

View File

@ -92,7 +92,7 @@ import re
import time
import codecs
from xml.parsers.expat import ParserCreate
from collections import defaultdict
from collections import defaultdict, OrderedDict
import string
from io import StringIO
from urllib.parse import urlparse
@ -1896,7 +1896,7 @@ class GedcomParser(UpdateCallback):
self.fams_map = stage_one.get_fams_map()
self.place_parser = PlaceParser()
self.inline_srcs = {}
self.inline_srcs = OrderedDict()
self.media_map = {}
self.genby = ""
self.genvers = ""

View File

@ -30,10 +30,10 @@ from gramps.gen.merge.diff import diff_dbs, import_as_dict
from gramps.gen.simple import SimpleAccess
from gramps.gen.utils.id import set_det_id
from gramps.cli import user
from gramps.gen.const import TEMP_DIR
from gramps.gen.const import TEMP_DIR, DATA_DIR
# the following defines where to find the test import and result files
TEST_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "Tstdata"))
TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests"))
# ------------------------------------------------------------------
# Local Functions
@ -57,7 +57,9 @@ class CompleteCheck(unittest.TestCase):
item2.to_struct())
if msg != "":
if hasattr(item1, "gramps_id"):
self.msg += "%s: %s\n" % (obj_type, item1.gramps_id)
self.msg += "%s: %s handle=%s\n" % \
(obj_type, item1.gramps_id,
getattr(item1, "handle"))
else:
self.msg += "%s: %s\n" % (obj_type, item1.get_name())
self.msg += msg
@ -153,20 +155,25 @@ class CompleteCheck(unittest.TestCase):
# The following make_test_function creates a test function (a method,
# to be precise) that compares the import file with the expected
# result '.gramps' file.
def make_test_function(tstfile, fname):
def test(self):
def make_tst_function(tstfile, fname):
def tst(self):
self._user = user.User(quiet=True)
f1 = os.path.join(TEST_DIR, tstfile)
f2 = os.path.join(TEST_DIR, (fname + ".gramps"))
fres = os.path.join(TEMP_DIR, (fname + ".difs"))
try:
os.remove(fres)
except OSError:
pass
print("\n**** %s ****" % tstfile)
set_det_id(True)
self.database1 = import_as_dict(f1, self._user)
set_det_id(True)
self.database2 = import_as_dict(f2, self._user)
self.assertIsNotNone(self.database1,
"Unable to import file: %s" % f1)
"Unable to import file: %s" % f1)
self.assertIsNotNone(self.database2,
"Unable to import expected result file: %s" % f2)
"Unable to import expected result file: %s" % f2)
if self.database2 is None or self.database1 is None:
return
diffs, added, missing = diff_dbs(self.database1,
@ -191,7 +198,7 @@ def make_test_function(tstfile, fname):
# if exception file matches exactly, we are done.
if self.msg != msg:
self.fail(self.msg)
return test
return tst
# let's see if we have a single file to run, example;
# "python test_import.py -i sample.ged"
@ -208,7 +215,7 @@ if __name__ == "__main__":
# via the modules' globals, taking advantage that they are a dict.
if tstfile: # single file mode
(fname, ext) = os.path.splitext(os.path.basename(tstfile))
test_func = make_test_function(tstfile, fname)
test_func = make_tst_function(tstfile, fname)
clname = 'Import_{0}'.format(tstfile)
globals()[clname] = type(clname,
(CompleteCheck,),
@ -216,12 +223,10 @@ if tstfile: # single file mode
# {"test:" + fname: test_func})
else:
for tstfile in os.listdir(TEST_DIR):
print(tstfile)
(fname, ext) = os.path.splitext(os.path.basename(tstfile))
if ext == ".gramps" or ext == ".difs":
if ext == ".gramps" or ext == ".difs" or ext == ".bak":
continue
test_func = make_test_function(tstfile, fname)
test_func = make_tst_function(tstfile, fname)
clname = 'Import_{0}'.format(tstfile)
globals()[clname] = type(clname,
(CompleteCheck,),