From df0800f071608f71fd070b61bed7a7d6433cf4a6 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 16 Nov 2021 11:57:24 -0500 Subject: [PATCH] New test and xls file for failing test --- .../enum_options_with_search/sponsors.xls | Bin 0 -> 9728 bytes tests/test_lookup_service.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/data/enum_options_with_search/sponsors.xls diff --git a/tests/data/enum_options_with_search/sponsors.xls b/tests/data/enum_options_with_search/sponsors.xls new file mode 100644 index 0000000000000000000000000000000000000000..7c6b1730a53b9dba4ba88bd6b26ff5ea056f899d GIT binary patch literal 9728 zcmeI1Yiv}<701tA@2=OzHoG>@HE~xaCA@+{{GlijVBXLGrZFzGrRA~M#tqnX4HTqA zSxC|*0#vt&D6Ud9>6f-tiinz~QKcy6TckKG4bVJ9DkrL{O8sK0qBd2+_WwUKcXsdf z8W4Oc%Gh`Aoij7PIdkScd;X89kr!W1eIU!LhvJ&=39*Un_=)~YfHwo zqA}R4x9mL35^Qs}XeMD$Lx#3GjrWG0Y_6}ruj@c&)!}UC-prQ1+#~&aIy(;_U!kyQ z^}6MpQ8aErJLL;ZUoeOp``0k@#L85GnnW(Wed+lHjmc+!oRE3*KY3{-WU-L!QOHP}CNlHdY`iDnxet$TAcpDu_auBX4;@C)ExGaZCwJtjpZ)Wbwmr#T{}B4$^PBgn z%QQTU241`8_= zjq-hZsVpt+*S7F(nI{X&)hk@=*xH2)EY`7HQ41w4Z=wYfGQg&Ri+Rf=Cq1%L_CkgE zG74ESw$59N8ELN^f`0(1vPhSajR+mYLs}G^V)`I$hP(h;l`AXmZASh*(kJ`y9uf9T zj*E=QU-c8-P=<0UceMcdziv*>{#7phcydz9rN5Kq9_{R$Z|8Z&4*&5ZeEFPlypOngLO5_!w1Ua?J z8OyKDJR6BhGG9^PJC%>?yFMS)cSF8X-;x)7Ps+y%Kf-Rq%>FGcEpqkhRk?imvYa_{ zhO3M44H}E|@=``Qlym3*I!W zVoM>2V6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zX{TRNZ0{=2Cz+BO!L|ONl?3+kw7F_QN{$e$f%@g=_R!BwZjx>8wI(;G2ONtbCyOH_ z4UJ9t5m$c15!j0@VUr>7@RG(op&?WR2o;XNv1W8&S(dQX5ID7@aZzXp(EuUp2vJ9% zewMJq5MoMT?`JJ|byciI%n@RaKy58yk0H=2-vGa2aZD$5=!6*WNRiIA>jzr))MlDP^AQpP!g&FI#fAAl_OAF zOL*E4*q_q+g9Hie5k*T@J3_T1P+LnFFa#`i$ivZ3!h`@}f+I|D1lG_JP8$Me?zCRS zk-){Ps6&k-)Hnj`YY8tH0=5sx!H(J7LhQPHYt;;M4$p9hg2uVj^eJx?g z5K>Cuj7S2P{-O>kM@TsW=Uq#9(-5#lL>|spB-958^^Q>Q2&}IqoHqpQ`9R=oOF~0{ z(BKFSj=(wH65cZeUa+MxdllOmzg-*AlEHrzwGJ3JKE! z1kA0rPfl|L=C%ZDNvsUefqNPfrUwYq9bvj7u)daHEs0|p2u+rd4iLBsnQ_4t#mx4s zuO(PZ;!q627c8MMKxlM?Mn_-`#-EF8y;PF+&8xlEUSl}b7q6dAeUvj9UWhpbMkR+53m)rj{1dv z1JcC#C71s4@=v||Tf?y{AH1tKLO#gDT?vn#}fwx7oILSUc% zZonHS9*(-qX zfxMu&u|6g@f4ejGXW4YVy!7qc-G9@z1EmRW^V^hc{IV$9|HZz?)3a>en-Jbk`TP}@ zV~20{A+{sGxoPD4b9ZN3z;Anw3BUb0KH2`<_H*OT^@f{gZhyIfWxwDil5akr-PtC( Hqigp+L5-ZR literal 0 HcmV?d00001 diff --git a/tests/test_lookup_service.py b/tests/test_lookup_service.py index dda8772c..15157e46 100644 --- a/tests/test_lookup_service.py +++ b/tests/test_lookup_service.py @@ -176,3 +176,21 @@ class TestLookupService(BaseTest): first_result = result[0] self.assertEquals(1000, first_result['CUSTOMER_NUMBER']) self.assertEquals('UVA - INTERNAL - GM USE ONLY', first_result['CUSTOMER_NAME']) + + def test_lookup_fails_for_xls(self): + BaseTest.load_test_spec('enum_options_with_search') + + # Using an old xls file should raise an error + file_model_xls = session.query(FileModel).filter(FileModel.name == 'sponsors.xls').first() + file_data_model_xls = session.query(FileDataModel).filter(FileDataModel.file_model_id == file_model_xls.id).first() + with self.assertRaises(ApiError) as ae: + LookupService.build_lookup_table(file_data_model_xls, 'CUSTOMER_NUMBER', 'CUSTOMER_NAME') + self.assertIn('Error opening excel file', ae.exception.args[0]) + + # Using an xlsx file should work + file_model_xlsx = session.query(FileModel).filter(FileModel.name == 'sponsors.xlsx').first() + file_data_model_xlsx = session.query(FileDataModel).filter(FileDataModel.file_model_id == file_model_xlsx.id).first() + lookup_model = LookupService.build_lookup_table(file_data_model_xlsx, 'CUSTOMER_NUMBER', 'CUSTOMER_NAME') + self.assertEqual(28, len(lookup_model.dependencies)) + self.assertIn('CUSTOMER_NAME', lookup_model.dependencies[0].data.keys()) + self.assertIn('CUSTOMER_NUMBER', lookup_model.dependencies[0].data.keys())