def test_load_xlsx(self):
url = 'http://test.com/the.xlsx'
self.url_pval.set_value(url)
self.url_pval.save()
xlsx_bytes = open(mock_xslx_path, "rb").read()
xlsx_table = pd.read_excel(mock_xslx_path)
# success case
with requests_mock.Mocker() as m:
m.get(url, content=xlsx_bytes, headers={'content-type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
self.press_fetch_button()
response = self.get_render()
self.assertEqual(response.content, make_render_json(xlsx_table))
# malformed file should put module in error state
with requests_mock.Mocker() as m:
m.get(url, content=b"there's just no way this is xlsx", headers={'content-type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
self.press_fetch_button()
self.wfmodule.refresh_from_db()
self.assertEqual(self.wfmodule.status, WfModule.ERROR)
评论列表
文章目录