From 306f73c69af1671f6d0763220efcc610454ca297 Mon Sep 17 00:00:00 2001 From: WinnyTroy Date: Wed, 12 Jun 2019 17:19:36 +0300 Subject: [PATCH] Check that whitespaces are stripped from urls --- .../spaces_in_choices_header.xls | Bin 27136 -> 8192 bytes pyxform/tests/bug_tests.py | 16 ++++++++++++++++ pyxform/tests_v1/test_whitespace.py | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/pyxform/tests/bug_example_xls/spaces_in_choices_header.xls b/pyxform/tests/bug_example_xls/spaces_in_choices_header.xls index 42509ef4f519d29574ecd903828c6556bdc6779a..987ba5ff21ad7cdc5ebb1c94552feff3109c8dc8 100644 GIT binary patch literal 8192 zcmeHMU2Ggz6+W{+&N_cyr*#M^jVFfsCvohieINuCyG=u>N=TH3pNC4@+1;@{$?nW* zXH2j}gqx5jQVG-tUaF#^yp$qZgcSaZ^9E9Zsv=V0$>9YGh;C64iqvHJzI$hO#@lRd zhqkDZ&*sj(=iGDex%b@jbFcHt?|T=Y{o(d2(gvTDv|Mj?OILz!puH)=^CBD2ChdB& z*^J0&uE7UL1J}Z}rg4B7lq?F*d>u*-r5j~E3ePwyn?w8qw9U1pcF@34@$d`8l!M}; zuFD)wcjd4Z7L%NMB_osZVkP{`@vO;@HL#qn*q_vYcMgHPD=RoC z8}WCdbJiR2-@5ek(5cDog%Ig^x7I_Woj%fmKH7o4s{_6JhIF30S`U-5f(7%b6ufd? znymBlX;t^mcd2^Id`8u`&977S?ep2@u4$-~x4GoDkj z{j-vnGwQCF6Wschp+i|#V!SfDtet-#WpLBPqyk@A?&d#m8}t**X6!n);d;Tap2sc^kByo`rJ)hUwS-t68W{nzR|_1^ZB0|MTnsmhwiz+E zW`=q#vxGZbP@lDjM_Su3J=Zp;>RwfC1Ilh~W4*|uYNzI5*G31oX;P~=of+FI+jaA# z6U>-?&4Ot_#bm%qTCl}%T^5hSR@7olE#jtFb$lPzW9o@8sucH^fR$x{xJybk0QBd@G zb$Qkk-9&6)%H2g`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cUfO|6h#7HWr_)7wOUyc^|_vG>TZ?xYQ I84LOU7Zx?{zW@LL diff --git a/pyxform/tests/bug_tests.py b/pyxform/tests/bug_tests.py index 0cbd6d6f2..8063df362 100644 --- a/pyxform/tests/bug_tests.py +++ b/pyxform/tests/bug_tests.py @@ -202,6 +202,22 @@ def runTest(self): pyxform.xls2json.parse_file_to_json(path_to_excel_file, warnings=warnings) self.assertEquals(len(warnings), 3, "Found " + str(len(warnings)) + " warnings") + def test_values_with_spaces_are_cleaned(self): + """ + Test that values with leading and trailing whitespaces are processed. + + This test checks that the submission_url provided is cleaned + of leading and trailing whitespaces. + """ + filename = "spaces_in_choices_header.xls" + path_to_excel_file = os.path.join(DIR, "bug_example_xls", filename) + survey_reader = SurveyReader(path_to_excel_file) + result = survey_reader.to_json_dict() + + self.assertEqual( + result["submission_url"], "https://odk.ona.io/random_person/submission" + ) + class TestChoiceNameAsType(unittest.TestCase): def test_choice_name_as_type(self): diff --git a/pyxform/tests_v1/test_whitespace.py b/pyxform/tests_v1/test_whitespace.py index 69a02c17b..838e8ac08 100644 --- a/pyxform/tests_v1/test_whitespace.py +++ b/pyxform/tests_v1/test_whitespace.py @@ -17,3 +17,19 @@ def test_over_trim(self): """, xml__contains=[''], ) + + def test_values_without_whitespaces_are_processed_successfully(self): + md = """ + | survey | | | | + | | type | label | name | + | | text | Ignored | Var | + | settings | | | | + | | id_string | public_key | submission_url | + | | tutorial_encrypted | MIIB | https://odk.ona.io/random_person/submission | + """ + + survey = self.md_to_pyxform_survey(md_raw=md) + expected = """""" + xml = survey._to_pretty_xml() + self.assertEqual(1, xml.count(expected)) + self.assertPyxformXform(md=md, xml__contains=expected, run_odk_validate=True)