From 28d2990b2f7f162513cce5142112f76d091880d5 Mon Sep 17 00:00:00 2001 From: Kelvin Muchiri Date: Fri, 21 Jul 2023 10:21:05 +0300 Subject: [PATCH] Fix AttributeError: 'NoneType' object has no attribute 'strip' when exporting form data (#2453) * fix bug when exporting SAV fix bug AttributeError: 'NoneType' object has no attribute 'strip'. * enhance test * refactor code * update docstring --- .../childrens_survey_sw_missing_en_label.xlsx | Bin 0 -> 9127 bytes .../libs/tests/utils/test_export_builder.py | 50 ++++++++ onadata/libs/utils/export_builder.py | 113 +++++++++++------- 3 files changed, 121 insertions(+), 42 deletions(-) create mode 100644 onadata/apps/logger/tests/fixtures/childrens_survey_sw_missing_en_label.xlsx diff --git a/onadata/apps/logger/tests/fixtures/childrens_survey_sw_missing_en_label.xlsx b/onadata/apps/logger/tests/fixtures/childrens_survey_sw_missing_en_label.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..9b5461ef07b3e5aa43badcff9450e7fc126606a4 GIT binary patch literal 9127 zcmbVSWmsHWvc=ssI3#!=bb#O?xVsY^f_pdap5X58?j9gG!QI{6-Fc9iH#d_vbAP-# zU;C*#r`KM)s&>_u5r>4r0)vBt17i<9Qv&-<5TD;`0rky54DVi^iz8a4+5t#@N6rDX zS05I5;L>v%Bt#m>n2B4+EeNXpGdsLbF9k3$kb*1PL#*B0A9b@AB`oL`0hHpJ{)(#p z5KWYNuDKn3kJgS1ECU&CUFdAWa+dtGz))$i^Zpgy-YjREFfoMfGfD9g@GZUlFJK>e zz5+EA?HM1xeB1O<-4DXBHdM-(c86;8ku*2`U?ECE=)}#ms{A^V%&uEZBGV<8tq}uR z-w(lYQQx(`Z|Nus1rG@zB8eVLwt3i%Ggccy_7KBmd1y?zsDrF#xD(1_s!Ftl-& zeB&x2ahQrt#H1w__&MdiZxd5S92U+ufjQyu8H7OyFff__3KQz{84hL)_Le|XT}w;T zcMj%eor(+6a{x5=C9QDB(ZyMpDw}N6fbXMlhj&N$3yS>E5KJbsu1bHMt&RZK1H;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