def test_export_4(self, mock_gdf): # --> test_export_3() with a valid extension already on test_wm = WorkflowManager([]) test_wm._result = mock.MagicMock(spec=pandas.DataFrame) test_wm.export(u'CSV', u'test_path.csv') test_wm.export(u'Excel', u'test_path.xlsx') test_wm.export(u'Stata', u'test_path.dta') test_wm.export(u'HTML', u'test_path.html') test_wm._result.to_csv.assert_called_once_with(u'test_path.csv') test_wm._result.to_stata.assert_called_once_with(u'test_path.dta') test_wm._result.to_excel.assert_called_once_with(u'test_path.xlsx') test_wm._result.to_html.assert_called_once_with(u'test_path.html') self.assertEqual(0, mock_gdf.call_count)
def test_export_3(self, mock_gdf): # --> the method works as expected for CSV, Excel, and Stata when _result is a DataFrame test_wm = WorkflowManager([]) test_wm._result = mock.MagicMock(spec=pandas.DataFrame) test_wm.export(u'CSV', u'test_path') test_wm.export(u'Excel', u'test_path') test_wm.export(u'Stata', u'test_path') test_wm.export(u'HTML', u'test_path') test_wm._result.to_csv.assert_called_once_with(u'test_path.csv') test_wm._result.to_stata.assert_called_once_with(u'test_path.dta') test_wm._result.to_excel.assert_called_once_with(u'test_path.xlsx') test_wm._result.to_html.assert_called_once_with(u'test_path.html') self.assertEqual(0, mock_gdf.call_count)
def test_export_5(self, mock_gdf): # --> test_export_3() with a Series that requires calling _get_dataframe() test_wm = WorkflowManager([]) test_wm._result = mock.MagicMock(spec=pandas.Series) # CSV mock_gdf.return_value = MagicMock(spec=pandas.DataFrame) test_wm.export(u'CSV', u'test_path') mock_gdf.assert_called_once_with(u'data', None, None) mock_gdf.return_value.to_csv.assert_called_once_with(u'test_path.csv') mock_gdf.reset_mock() # Excel test_wm.export(u'Excel', u'test_path', 5) mock_gdf.assert_called_once_with(u'data', 5, None) mock_gdf.return_value.to_excel.assert_called_once_with(u'test_path.xlsx') mock_gdf.reset_mock() # Stata test_wm.export(u'Stata', u'test_path', 5, 10) mock_gdf.assert_called_once_with(u'data', 5, 10) mock_gdf.return_value.to_stata.assert_called_once_with(u'test_path.dta') mock_gdf.reset_mock() # HTML test_wm.export(u'HTML', u'test_path', threshold=10) mock_gdf.assert_called_once_with(u'data', None, 10) mock_gdf.return_value.to_html.assert_called_once_with(u'test_path.html')