From 8cda91a377480770697e27781877f044c4442473 Mon Sep 17 00:00:00 2001 From: prculley Date: Thu, 26 May 2016 11:22:06 -0500 Subject: [PATCH] moved test directory, tweaked tests, and fixes --- .../tests}/FTM_16dec2015a-mod1.ged | 0 .../tests}/FTM_16dec2015a-mod1.gramps | Bin .../tests}/MixInlineXrefNote.ged | 10 ------ data/tests/MixInlineXrefNote.gramps | Bin 0 -> 748 bytes .../test/Tstdata => data/tests}/Paris.ged | 1 - .../Tstdata => data/tests}/bug 8322 test.ged | 0 .../tests}/bug 8322 test.gramps | Bin .../test/Tstdata => data/tests}/paris.gramps | Bin .../test/Tstdata => data/tests}/sample.ged | 0 .../test/Tstdata => data/tests}/sample.gramps | Bin data/tests/test_FTM_CONC.difs | 17 ++++++++++ .../Tstdata => data/tests}/test_FTM_CONC.ged | 0 .../tests}/test_FTM_CONC.gramps | Bin .../test/Tstdata => data/tests}/vcard.difs | 2 +- .../test/Tstdata => data/tests}/vcard.gramps | Bin .../test/Tstdata => data/tests}/vcard.vcf | 0 gramps/gen/utils/id.py | 2 +- gramps/plugins/lib/libgedcom.py | 4 +-- .../test/Tstdata/MixInlineXrefNote.gramps | Bin 1036 -> 0 bytes gramps/plugins/test/Tstdata/paris.gramps.bak | Bin 3263 -> 0 bytes gramps/plugins/test/test_imports.py | 31 ++++++++++-------- 21 files changed, 39 insertions(+), 28 deletions(-) rename {gramps/plugins/test/Tstdata => data/tests}/FTM_16dec2015a-mod1.ged (100%) rename {gramps/plugins/test/Tstdata => data/tests}/FTM_16dec2015a-mod1.gramps (100%) rename {gramps/plugins/test/Tstdata => data/tests}/MixInlineXrefNote.ged (81%) create mode 100644 data/tests/MixInlineXrefNote.gramps rename {gramps/plugins/test/Tstdata => data/tests}/Paris.ged (99%) rename {gramps/plugins/test/Tstdata => data/tests}/bug 8322 test.ged (100%) rename {gramps/plugins/test/Tstdata => data/tests}/bug 8322 test.gramps (100%) rename {gramps/plugins/test/Tstdata => data/tests}/paris.gramps (100%) rename {gramps/plugins/test/Tstdata => data/tests}/sample.ged (100%) rename {gramps/plugins/test/Tstdata => data/tests}/sample.gramps (100%) create mode 100644 data/tests/test_FTM_CONC.difs rename {gramps/plugins/test/Tstdata => data/tests}/test_FTM_CONC.ged (100%) rename {gramps/plugins/test/Tstdata => data/tests}/test_FTM_CONC.gramps (100%) rename {gramps/plugins/test/Tstdata => data/tests}/vcard.difs (77%) rename {gramps/plugins/test/Tstdata => data/tests}/vcard.gramps (100%) rename {gramps/plugins/test/Tstdata => data/tests}/vcard.vcf (100%) delete mode 100644 gramps/plugins/test/Tstdata/MixInlineXrefNote.gramps delete mode 100644 gramps/plugins/test/Tstdata/paris.gramps.bak diff --git a/gramps/plugins/test/Tstdata/FTM_16dec2015a-mod1.ged b/data/tests/FTM_16dec2015a-mod1.ged similarity index 100% rename from gramps/plugins/test/Tstdata/FTM_16dec2015a-mod1.ged rename to data/tests/FTM_16dec2015a-mod1.ged diff --git a/gramps/plugins/test/Tstdata/FTM_16dec2015a-mod1.gramps b/data/tests/FTM_16dec2015a-mod1.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/FTM_16dec2015a-mod1.gramps rename to data/tests/FTM_16dec2015a-mod1.gramps diff --git a/gramps/plugins/test/Tstdata/MixInlineXrefNote.ged b/data/tests/MixInlineXrefNote.ged similarity index 81% rename from gramps/plugins/test/Tstdata/MixInlineXrefNote.ged rename to data/tests/MixInlineXrefNote.ged index 679c9ca90..857806f48 100644 --- a/gramps/plugins/test/Tstdata/MixInlineXrefNote.ged +++ b/data/tests/MixInlineXrefNote.ged @@ -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 diff --git a/data/tests/MixInlineXrefNote.gramps b/data/tests/MixInlineXrefNote.gramps new file mode 100644 index 0000000000000000000000000000000000000000..b1367cbd184b81a96cba7e366521f1b493a4a971 GIT binary patch literal 748 zcmV_$RMF2x@fD_6)l27IhDbr5_vQHcYf z8!Xu4MgLugKpjHig3*M@atTf>8C5JPsk6T0d!*O#x*fmk*uJ~22c6@(K(c~S886HU zdW+K~izalHp}{K4*gC{!vynuTL`H=8#6u5R!q9!n75X7o(8P#W6;(!~B2Lvhnu+Bz z&9W+?+Gr#c3V27ew<@TeX1Q2#CD+m8^t-OE{YFYIpel=k;56t~IrT;(g)M2CML9Gl z{op+KHZOfQ7RxGMN3}M1TbvMEsl%L!JgeD(BMZUNg7PE-*?)WbM~rn)46!+c$XV}< zT#()c%wC%GonaN;(3>+}0^EnVUYS6tJyPo&j<`ytTA(p(Z0aE4C6$GWM(HaIGYPSF zO*P)SIxZBG>;)~dl>fDCePhjR98Nto_IT=%Vf;hBU&tYp0J zUc1Ix`i9prnzr*+n&dNRo*TQLru8au>vN3I+S}o8TR+HuT1~vAr&0x%Ipjc&p{YI= zMyKAdiD|fYY}-#Oc6SFm-NN=if=!KW$M$!yYtZS3I({~`9rg4es@DQ**829#C(PV^ zx!&PopU8t;#?=Q_KOlFEGf6W`O|ds+#=r}4<<_K1z&33A=C)#!cI>C0H@9f~pV0OV eZ-w^X)i&9WtyiFah|OQ2=;R-cfEPNl2><}Yb9PJs literal 0 HcmV?d00001 diff --git a/gramps/plugins/test/Tstdata/Paris.ged b/data/tests/Paris.ged similarity index 99% rename from gramps/plugins/test/Tstdata/Paris.ged rename to data/tests/Paris.ged index 40e77771a..02cc9bc89 100644 --- a/gramps/plugins/test/Tstdata/Paris.ged +++ b/data/tests/Paris.ged @@ -272,4 +272,3 @@ 1 CHIL @134I@ 1 CHIL @179I@ 0 TRLR - diff --git a/gramps/plugins/test/Tstdata/bug 8322 test.ged b/data/tests/bug 8322 test.ged similarity index 100% rename from gramps/plugins/test/Tstdata/bug 8322 test.ged rename to data/tests/bug 8322 test.ged diff --git a/gramps/plugins/test/Tstdata/bug 8322 test.gramps b/data/tests/bug 8322 test.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/bug 8322 test.gramps rename to data/tests/bug 8322 test.gramps diff --git a/gramps/plugins/test/Tstdata/paris.gramps b/data/tests/paris.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/paris.gramps rename to data/tests/paris.gramps diff --git a/gramps/plugins/test/Tstdata/sample.ged b/data/tests/sample.ged similarity index 100% rename from gramps/plugins/test/Tstdata/sample.ged rename to data/tests/sample.ged diff --git a/gramps/plugins/test/Tstdata/sample.gramps b/data/tests/sample.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/sample.gramps rename to data/tests/sample.gramps diff --git a/data/tests/test_FTM_CONC.difs b/data/tests/test_FTM_CONC.difs new file mode 100644 index 000000000..c372c4222 --- /dev/null +++ b/data/tests/test_FTM_CONC.difs @@ -0,0 +1,17 @@ +Mismatch on file: test_FTM_CONC.ged +Source: S0029 handle=0000000500000005 + Diff on: Source, pubinfo + 73: Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date:2009; + 74: Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date: 2009; +Citation: C0000 handle=0000000600000006 + Diff on: Citation, page + 102: Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll:M432_394; Page: 435B; Image: 248 + 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 + 54: The FTM way to do a CONC line with space at end --><-- + 55: The FTM way to do a CONC line with space at end --> <-- +Note: N0002 handle=0000000400000004 + Diff on: Note, text, string + 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. + 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. diff --git a/gramps/plugins/test/Tstdata/test_FTM_CONC.ged b/data/tests/test_FTM_CONC.ged similarity index 100% rename from gramps/plugins/test/Tstdata/test_FTM_CONC.ged rename to data/tests/test_FTM_CONC.ged diff --git a/gramps/plugins/test/Tstdata/test_FTM_CONC.gramps b/data/tests/test_FTM_CONC.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/test_FTM_CONC.gramps rename to data/tests/test_FTM_CONC.gramps diff --git a/gramps/plugins/test/Tstdata/vcard.difs b/data/tests/vcard.difs similarity index 77% rename from gramps/plugins/test/Tstdata/vcard.difs rename to data/tests/vcard.difs index b8b8bf512..35b0519ee 100644 --- a/gramps/plugins/test/Tstdata/vcard.difs +++ b/data/tests/vcard.difs @@ -1,5 +1,5 @@ Mismatch on file: vcard.vcf -Person: I0019 +Person: I0019 handle=0000001800000018 Diff on: Person, primary_name, surname list #2, primary : True : False diff --git a/gramps/plugins/test/Tstdata/vcard.gramps b/data/tests/vcard.gramps similarity index 100% rename from gramps/plugins/test/Tstdata/vcard.gramps rename to data/tests/vcard.gramps diff --git a/gramps/plugins/test/Tstdata/vcard.vcf b/data/tests/vcard.vcf similarity index 100% rename from gramps/plugins/test/Tstdata/vcard.vcf rename to data/tests/vcard.vcf diff --git a/gramps/gen/utils/id.py b/gramps/gen/utils/id.py index 06852d3c7..d6587fbf5 100644 --- a/gramps/gen/utils/id.py +++ b/gramps/gen/utils/id.py @@ -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. diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index cfdde921d..d7e2059bb 100755 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -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 = "" diff --git a/gramps/plugins/test/Tstdata/MixInlineXrefNote.gramps b/gramps/plugins/test/Tstdata/MixInlineXrefNote.gramps deleted file mode 100644 index eae98ab4a08209c50e92531ad3b1a80d03916855..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1036 zcmV+n1oQhJiwFqPP(xP&|4nIlNp5UuZe>_UoC!W~yteBg$|Dgoz8p9Y^PAR%^D#UNe!HFx=l|S|P)rngBsoQQ4_A}% z5IHT3KS`2iImXxXYh>E!>vV#=cE9amJi2wxoRw19CB{oV+RCJOqLFF~xx|2vO{5tF zza6XC0njZL^znS~szqQPLcxlXn98CFP9!N&G%l#qf#bVgujQV%{Ek!QecpB(pyqq089g1w(LNmJyM$tmbhY4t;>4kb~fJGI`Q}<=>n}1#=li$`_|ghC{Tr>2SR;oPltA_JssM$wiXKYK@?Q& zf$*NS+fv468=Cjz!rJCNaewxnxbNDOM{8fF39~@jdo*SjVr&lHOQN4z{ zdPRaSSPTa%4gCPuJR6XUwTuo`z`3;*eaq_<%_{Ron%>W#`N7)5G%HVwTdre;Hr^ip zD)poM@AYs+Pca3XIp#o)qIzZ9so%@q7Y6uy2L-E0Z0`8O{9;|_}9jUZX3^t-1B z@lIbu3u{k?Zm)OuP@cAJ%Ai=m7D3V8OTM~Ok0yVsOQ5`QK2c63Nh&QAeNpx_a09H} zl2ifMgk4?Ijo4l@cA+o2eIs;r={G|AuS(l{8+NtRjo6(n_UL*znfimv`up$Hzq6yi|LgQOEjWDwZ2x73XWsz}0zlIZ G4*&qAtP67h diff --git a/gramps/plugins/test/Tstdata/paris.gramps.bak b/gramps/plugins/test/Tstdata/paris.gramps.bak deleted file mode 100644 index 618b2147b287841271bccae8032f06a9f8d98f88..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3263 zcmZvdX*?9%`^K%ANA|{^WXq68mPDjxFoZB9`(Q@KzRnC;vko)1WZwsg2a$a!d#Gf| zz9!q)LNVFPZ|eW{|K|I-&V8Rb;TJI~pgdB%aorB$q>0+LUeC6kP9N zHff=gvCg&AB#Vp3du&-nR8j?2SVW<~h_S@Vp8gv|l*8 zd!`boc-DV9RH}SVQmqrU8j=4u6N?S<{k<`^i3w^=x}7&ju-*MN5af0|b8_0#3{C73 z8`;W(`+dP&`RIEvX}jC@yI!roZei-hosWB`SG?MrWSY;O*$G1(#}*T+W|wwLdelm8 zEdG>nJL+(Lx3?+Lp1BgAE>r%%X;(GTAfjs9U#L{<%+@O8YyW(!I_plA2YKI(f8sw|%*nUDJ*$ojlD_nupHd9k8*o?6Pk9a1r66q41MFQ;}RUyOYqhHLMl2ISt@fe!*CQfHEKV|1U$8VgpMgk{RD&`Y z0ti70MyMZJiVRrl9gC?&(+<*L;>1epS04HrUP7t2=UC6Txdv!Me1`l8jJfjbJVTyS znBLZM4W(W$Zc-L!-Qd%s+);%%GzyB|%3Y`+x6CWkLh~?wgiE;qpis;>ThdEje0XkH-nv-t@7~JH=Z29Dtdz8>bk&cM5Fvirk(^}YyvZQmT#OY_b>?pVU6;xEL6jm zfD)~T1CYKaff6&Va|}FLcGp?37zA=n zb)z1<;Nf7(KoBfZD-L3*k2bE5UHiK@WuV$+L7u5Q@jF38k9cNkLyQyV9)pL&7!6Qa z&tLmcirVEGk!0MW*diR>D8I?}w`?bTT8}TKWBR*bw;8^ref-xG$U#k8&Q1_m-56Z& zq@i{P0+n6S+UGwHPEg&~j(HZBj`}lP<=!Z0ch{O!e7X<0RI-;eOFNpC%j z-EM3th$=jkd1Z*afomPVeneD#(I`E;fOREJNIZ3bC-IWv_KPkHtp%iO`xw7=aU{QP z3bqDbCm-)|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(TtUHsnd8l?zQT=wF@RZuyRQCbQfyRk^oOF{YI zFN=YyV62ncqR+F_$-}kdxC!kz6av2@0jg}Ht29^09jm`tind0mJ}uF$BWYOyfs4XYvx*n>Ry-jPPDWS-!;P0ukrk*< zNX{&Kn2dCdU!H6)MFy^n$=|7RS*a;;INH^94K~@9h>YFH@_3A9ivHwIbmUVc4dPNzI zm`)bq0vF2JaP#Fi3$xbS^Wg5^iSGJtYR}@zM{mGK&&Wq#C#ThQ9f+%@>sIDHf?Px) zVzsP6@nA-6d)b*tp7^e3T)~BM8r*ycRxg diff --git a/gramps/plugins/test/test_imports.py b/gramps/plugins/test/test_imports.py index 49f879550..05e1cf417 100644 --- a/gramps/plugins/test/test_imports.py +++ b/gramps/plugins/test/test_imports.py @@ -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,),