From b5d903c603f4daa984f5a8d85aacd313beaaeebf Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 11 Jun 2019 19:52:51 +0100 Subject: [PATCH] Test import of various trace formats Fixes #2254 --- test/gpx/fixtures/f.gpx | Bin 507 -> 992 bytes test/gpx/fixtures/g.gpx | Bin 10240 -> 10240 bytes test/gpx/fixtures/h.gpx | Bin 469 -> 536 bytes test/gpx/fixtures/i.gpx | Bin 492 -> 602 bytes test/models/trace_test.rb | 95 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 91 insertions(+), 4 deletions(-) diff --git a/test/gpx/fixtures/f.gpx b/test/gpx/fixtures/f.gpx index 614a0e8bad008fdc66ab5a9daa4c280dad3e89d0..1466dbc95e51294349ab0b3099dbbd4ea300a4fd 100644 GIT binary patch delta 616 zcmey({D9pcz?+#xgn@y9gJDtcFQ4#}QB~253=Dgj7#LU?WEc|l(hDj=LpT|jC;WC7%tnJ8#(HEe47v-NKw36KwIrcv`2^HbTEWf0$nt`jfdNeP2FB+%83@!r4>qY? zuDc*lIbgEw8S&{eUI=a8&LumEGdDxj?%%qjmNiA3neV?pUsvwFO=gzxt`q03tU6oh zBH^}4w>~6tduX41S^h)gxK9eJzX&X-mVdBl@}X6F$5)^I7Ao_Ev-L&BT0hOVzvqSA zl9BNa3AePixjL)FptMhYon4_-uVnX&f3>D;Q-^7XErj|;!7h?oOgaMF#|wbCc+7v7yd;jHtv8?K(S&OA`= z*?7LE%JKx?t2@)!OiQbU%#MHVP`ROeJ@CYd8pZ&gV8ILXJ??tn{azsz+1t1+W0K*< z;u(MI=Qgencz(`9&ed?H>Vl0uahl7ebW=}CCi)w8Kkn(fp}9e1-W18w?d4pj(-Rs_ zA530p(mp9i=jFo3`pVk-cYK;2AGcd!=SMlV3(KTGOZ7BgE);yH{^0?8fHxzP95W(D zC$D0ZtAj=(Dr0 E0D8~sm;e9( delta 153 zcmaFB{+rn#z?+#xgn@y9gJD`&s9X5SsH$j228O*%3=FIcG7N@#=>-*`A)E}%HOVhR zSm(SC*=Uf%7|+Ng$Bavp1kf-B2A~-XTN*(us1d9XBT6f{85mh!Ff%ZKi2!d_HjpAl MAoK>(vq1V70CR61q5uE@ diff --git a/test/gpx/fixtures/g.gpx b/test/gpx/fixtures/g.gpx index 7e4c07c41ddaf94d1ee23025bcfb19bf69198e2e..e0c32b520274eae424aa193126ef89c8f229629a 100644 GIT binary patch delta 232 zcmZn&Xb50ToXFTAVr*<=W^8V1WMsf#U}#`uXuzOgFxikXWiun=e-_51iHt20X2uML zXvz%C5X!8X1T1w8Omz*+LJW|*$}cgH66kzC{aMtfu!7yOF_Y=Br`YF&d9(3-359En?Es2 G$N>OXRXKnF delta 49 zcmZn&Xb505oXFTAVq{`&WMF1!YHq?{U}#`yY|5ZuFxikXWiun=f0oS`xC~^0#03@r DHRTPR diff --git a/test/gpx/fixtures/h.gpx b/test/gpx/fixtures/h.gpx index a0e75cecce6c18e5c1db788e5af5f40cc5827c92..ed0c3effc7be77cc61e59f7cf45dc63c266bfaec 100644 GIT binary patch delta 533 zcmV+w0_y$M1DFJVABzY8-01&Y00ZrnOOKl{5P);$S6JM^HV$Nq2rKo_y=62WcQP}oTe=TV&mXh3+!Bv$jA>&^4~GM6Exoo{Uv;H*hetI! z?sc_v&%6%8+Gzkgfxdixe9kwr&b+FD57XrG7+1?B!H$5m6!0&b8LM=>H%M{YR^EmSuUvU->mk*oyYeEOJldRRQDKx38 zW}BI*vQ{{jxz74C3ka_kYM;@4AMaY0) X5ClP!wE++e|hI8gAEbd?%NK!?PEA3%>=}MK_N>y(TcnR8o z5q1(Df5#?G(@V3Ls#(oHV%$fF6-L?3Cintxy9XaU1Hl|z0JY_M_U1_SOtJm@K)6e84 zzLk-HQxcJnID|K%He!jr;beibx?Be602uCkT&U)kA z=2ndt5is5&)PH06Grg^@r%CU~yZo$`@XJE)wB&h_GC}>+yZ)(0(3NICSjgsCTIBvV z3VL$+sO`0`BqYJz%rZeI+ee^1GOq;nV^At53lPBI&243R2}`nR$zXc_Ve&6d{==KU z_mlkW4`u{q`rkfHrbf`IF@8H_^xc;SK@bE%5ClOG1VIo4K@bE%5ClOG1VIo4LB5&4 LT6f%R04M+e8iMEj diff --git a/test/gpx/fixtures/i.gpx b/test/gpx/fixtures/i.gpx index 6c9010c4694e9f239e0ec3544fb3b7aa0f2d4432..e5152c466636ce82bf6c19be8bf47e3a6dd54be1 100644 GIT binary patch literal 602 zcmV-g0;T;zT4*^jL0KkKS!@Z}6aWGU|AOcc03c8U|M$^`PFR2M-@rfs00=+=`~Uy} z%m4rY000000n7jZ0000000GPZ00000000105@bypk3fWaNwPf>JrhjPp{eOSr`hS| zBzzv3V{>l2%}pS>XGqXDyVZ z&s*%3;k0vnnzi5a;WvA&G*s0dZNz6F-O%L?T(~X@P{f< z4%9i7-fUh)ovBE%?t5aZ2>Uj<-ovdLO-uJRHY4Qaz;qGh7HS-`mm|jt!5NfAqQu0ukx|ZY zUR;JmbUGZx$nJL%HZD;b6f_a6*m5_SGHiG^x(vz`FJ8f=p_r7lmzS41UTx^Ptqa$Z oOWKCidMc}d`a=|Kv``VqyPW_ literal 492 zcmVGyk5Qn+43ANofHY_s0icv7kkFZ_Gy$VbO*Cj|&}ow)fB*mh&;S4c0Fpvznq@p{ zo>SEI4X6V^00HWG{?(({Ku0xB$hOas(fGDBRY5^_o@%0+vo+WFYRfrdj7HyEMfKH^ie*7iqRLfh`_Bs# z>V7@IrkRCHLb*i3fmIAK4yA+Cc7oC&lkBmo#O4Q@uWLzh;ohv)PIAJ`%wnvhiOOGn zrT7j+jB75i!aPZ$w95KLTaIAM$a=W^5WGvMS!bLF8V`CA7}5+uKvJ7Xt?{{KlCW}t zGHD6{yk!ySs958G^|xrjbKIzLK&>t-ysE3dFT}8L;xV3@ECy>xksrtXdVQ#jMjJFq iX$Wv1DAdS;D>6(mtnZwiu&@w+i@744C`fqHBRT;3f900| diff --git a/test/models/trace_test.rb b/test/models/trace_test.rb index 81120f0e7..24c66c490 100644 --- a/test/models/trace_test.rb +++ b/test/models/trace_test.rb @@ -149,10 +149,10 @@ class TraceTest < ActiveSupport::TestCase check_xml_file("b", "66179ca44f1e93d8df62e2b88cbea732") check_xml_file("c", "848caa72f2f456d1bd6a0fdf228aa1b9") check_xml_file("d", "abd6675fdf3024a84fc0a1deac147c0d") - check_xml_file("f", "848caa72f2f456d1bd6a0fdf228aa1b9") - check_xml_file("g", "848caa72f2f456d1bd6a0fdf228aa1b9") - check_xml_file("h", "848caa72f2f456d1bd6a0fdf228aa1b9") - check_xml_file("i", "848caa72f2f456d1bd6a0fdf228aa1b9") + check_xml_file("f", "a7c05d676c77dc14369c21be216a3713") + check_xml_file("g", "a7c05d676c77dc14369c21be216a3713") + check_xml_file("h", "a7c05d676c77dc14369c21be216a3713") + check_xml_file("i", "a7c05d676c77dc14369c21be216a3713") end def test_large_picture @@ -241,6 +241,93 @@ class TraceTest < ActiveSupport::TestCase end end + def test_import_handles_bz2 + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace = create(:trace, :fixture => "c") + + trace.import + + assert_equal 1, trace.size + end + end + + def test_import_handles_plain + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace = create(:trace, :fixture => "a") + + trace.import + + assert_equal 1, trace.size + end + end + + def test_import_handles_gz + trace = create(:trace, :fixture => "d") + + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace.import + + assert_equal 1, trace.size + ensure + trace.destroy + end + end + + def test_import_handles_zip + trace = create(:trace, :fixture => "f") + + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace.import + + assert_equal 2, trace.size + ensure + trace.destroy + end + end + + def test_import_handles_tar + trace = create(:trace, :fixture => "g") + + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace.import + + assert_equal 2, trace.size + ensure + trace.destroy + end + end + + def test_import_handles_tar_gz + trace = create(:trace, :fixture => "h") + + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace.import + + assert_equal 2, trace.size + ensure + trace.destroy + end + end + + def test_import_handles_tar_bz2 + trace = create(:trace, :fixture => "i") + + FakeFS do + FakeFS::FileSystem.clone(Rails.root.join("test", "gpx")) + trace.import + + assert_equal 2, trace.size + ensure + trace.destroy + end + end + private def check_query(query, traces) -- 2.39.5