moved test directory, tweaked tests, and fixes
This commit is contained in:
parent
7646d41774
commit
8cda91a377
@ -21,24 +21,14 @@
|
|||||||
1 NOTE @N0@
|
1 NOTE @N0@
|
||||||
1 NOTE Inline 1
|
1 NOTE Inline 1
|
||||||
1 SOUR Inline Source 1
|
1 SOUR Inline Source 1
|
||||||
1 OBJE
|
|
||||||
2 FILE Inline1
|
|
||||||
2 FORM jpg
|
|
||||||
0 @N0@ NOTE
|
0 @N0@ NOTE
|
||||||
1 CONC XREF N0
|
1 CONC XREF N0
|
||||||
0 @I01@ INDI
|
0 @I01@ INDI
|
||||||
1 NAME Living01
|
1 NAME Living01
|
||||||
1 SEX M
|
1 SEX M
|
||||||
1 SOUR inline Source 2
|
1 SOUR inline Source 2
|
||||||
1 OBJE
|
|
||||||
2 FILE Inline2
|
|
||||||
3 FORM jpg
|
|
||||||
0 @S1@ SOUR
|
0 @S1@ SOUR
|
||||||
1 TITL Source S1
|
1 TITL Source S1
|
||||||
0 @S01@ SOUR
|
0 @S01@ SOUR
|
||||||
1 TITL Source S01
|
1 TITL Source S01
|
||||||
0 @O1@ OBJE
|
|
||||||
1 FILE XREF1
|
|
||||||
0 @O1@ OBJE
|
|
||||||
1 FILE XREF2
|
|
||||||
0 TRLR
|
0 TRLR
|
BIN
data/tests/MixInlineXrefNote.gramps
Normal file
BIN
data/tests/MixInlineXrefNote.gramps
Normal file
Binary file not shown.
@ -272,4 +272,3 @@
|
|||||||
1 CHIL @134I@
|
1 CHIL @134I@
|
||||||
1 CHIL @179I@
|
1 CHIL @179I@
|
||||||
0 TRLR
|
0 TRLR
|
||||||
|
|
17
data/tests/test_FTM_CONC.difs
Normal file
17
data/tests/test_FTM_CONC.difs
Normal 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.
|
@ -1,5 +1,5 @@
|
|||||||
Mismatch on file: vcard.vcf
|
Mismatch on file: vcard.vcf
|
||||||
Person: I0019
|
Person: I0019 handle=0000001800000018
|
||||||
Diff on: Person, primary_name, surname list #2, primary
|
Diff on: Person, primary_name, surname list #2, primary
|
||||||
<class 'bool'>: True
|
<class 'bool'>: True
|
||||||
<class 'bool'>: False
|
<class 'bool'>: False
|
@ -10,7 +10,7 @@
|
|||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (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
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
@ -92,7 +92,7 @@ import re
|
|||||||
import time
|
import time
|
||||||
import codecs
|
import codecs
|
||||||
from xml.parsers.expat import ParserCreate
|
from xml.parsers.expat import ParserCreate
|
||||||
from collections import defaultdict
|
from collections import defaultdict, OrderedDict
|
||||||
import string
|
import string
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
@ -1896,7 +1896,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.fams_map = stage_one.get_fams_map()
|
self.fams_map = stage_one.get_fams_map()
|
||||||
|
|
||||||
self.place_parser = PlaceParser()
|
self.place_parser = PlaceParser()
|
||||||
self.inline_srcs = {}
|
self.inline_srcs = OrderedDict()
|
||||||
self.media_map = {}
|
self.media_map = {}
|
||||||
self.genby = ""
|
self.genby = ""
|
||||||
self.genvers = ""
|
self.genvers = ""
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -30,10 +30,10 @@ from gramps.gen.merge.diff import diff_dbs, import_as_dict
|
|||||||
from gramps.gen.simple import SimpleAccess
|
from gramps.gen.simple import SimpleAccess
|
||||||
from gramps.gen.utils.id import set_det_id
|
from gramps.gen.utils.id import set_det_id
|
||||||
from gramps.cli import user
|
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
|
# 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
|
# Local Functions
|
||||||
@ -57,7 +57,9 @@ class CompleteCheck(unittest.TestCase):
|
|||||||
item2.to_struct())
|
item2.to_struct())
|
||||||
if msg != "":
|
if msg != "":
|
||||||
if hasattr(item1, "gramps_id"):
|
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:
|
else:
|
||||||
self.msg += "%s: %s\n" % (obj_type, item1.get_name())
|
self.msg += "%s: %s\n" % (obj_type, item1.get_name())
|
||||||
self.msg += msg
|
self.msg += msg
|
||||||
@ -153,20 +155,25 @@ class CompleteCheck(unittest.TestCase):
|
|||||||
# The following make_test_function creates a test function (a method,
|
# The following make_test_function creates a test function (a method,
|
||||||
# to be precise) that compares the import file with the expected
|
# to be precise) that compares the import file with the expected
|
||||||
# result '.gramps' file.
|
# result '.gramps' file.
|
||||||
def make_test_function(tstfile, fname):
|
def make_tst_function(tstfile, fname):
|
||||||
def test(self):
|
def tst(self):
|
||||||
self._user = user.User(quiet=True)
|
self._user = user.User(quiet=True)
|
||||||
f1 = os.path.join(TEST_DIR, tstfile)
|
f1 = os.path.join(TEST_DIR, tstfile)
|
||||||
f2 = os.path.join(TEST_DIR, (fname + ".gramps"))
|
f2 = os.path.join(TEST_DIR, (fname + ".gramps"))
|
||||||
fres = os.path.join(TEMP_DIR, (fname + ".difs"))
|
fres = os.path.join(TEMP_DIR, (fname + ".difs"))
|
||||||
|
try:
|
||||||
|
os.remove(fres)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
print("\n**** %s ****" % tstfile)
|
||||||
set_det_id(True)
|
set_det_id(True)
|
||||||
self.database1 = import_as_dict(f1, self._user)
|
self.database1 = import_as_dict(f1, self._user)
|
||||||
set_det_id(True)
|
set_det_id(True)
|
||||||
self.database2 = import_as_dict(f2, self._user)
|
self.database2 = import_as_dict(f2, self._user)
|
||||||
self.assertIsNotNone(self.database1,
|
self.assertIsNotNone(self.database1,
|
||||||
"Unable to import file: %s" % f1)
|
"Unable to import file: %s" % f1)
|
||||||
self.assertIsNotNone(self.database2,
|
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:
|
if self.database2 is None or self.database1 is None:
|
||||||
return
|
return
|
||||||
diffs, added, missing = diff_dbs(self.database1,
|
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 exception file matches exactly, we are done.
|
||||||
if self.msg != msg:
|
if self.msg != msg:
|
||||||
self.fail(self.msg)
|
self.fail(self.msg)
|
||||||
return test
|
return tst
|
||||||
|
|
||||||
# let's see if we have a single file to run, example;
|
# let's see if we have a single file to run, example;
|
||||||
# "python test_import.py -i sample.ged"
|
# "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.
|
# via the modules' globals, taking advantage that they are a dict.
|
||||||
if tstfile: # single file mode
|
if tstfile: # single file mode
|
||||||
(fname, ext) = os.path.splitext(os.path.basename(tstfile))
|
(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)
|
clname = 'Import_{0}'.format(tstfile)
|
||||||
globals()[clname] = type(clname,
|
globals()[clname] = type(clname,
|
||||||
(CompleteCheck,),
|
(CompleteCheck,),
|
||||||
@ -216,12 +223,10 @@ if tstfile: # single file mode
|
|||||||
# {"test:" + fname: test_func})
|
# {"test:" + fname: test_func})
|
||||||
else:
|
else:
|
||||||
for tstfile in os.listdir(TEST_DIR):
|
for tstfile in os.listdir(TEST_DIR):
|
||||||
print(tstfile)
|
|
||||||
|
|
||||||
(fname, ext) = os.path.splitext(os.path.basename(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
|
continue
|
||||||
test_func = make_test_function(tstfile, fname)
|
test_func = make_tst_function(tstfile, fname)
|
||||||
clname = 'Import_{0}'.format(tstfile)
|
clname = 'Import_{0}'.format(tstfile)
|
||||||
globals()[clname] = type(clname,
|
globals()[clname] = type(clname,
|
||||||
(CompleteCheck,),
|
(CompleteCheck,),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user