예제 #1
0
    def test_table_3(self):
        '''
        _make_table():

        - "count frequency" is False
        - file extension not on "pathname"
        - there are several IndexedPiece objects
        '''
        test_wm = WorkflowManager([])
        test_wm.settings(None, 'count frequency', False)
        test_wm._result = [mock.MagicMock(spec_set=pandas.DataFrame) for _ in range(5)]
        test_wm._data = ['boop' for _ in range(len(test_wm._result))]
        top_x = None
        threshold = None
        pathname = 'test_path'

        test_wm._make_table('CSV', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Excel', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Stata', pathname, top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('HTML', pathname, top_x, threshold)  # pylint: disable=protected-access

        for i in range(len(test_wm._result)):
            test_wm._result[i].to_csv.assert_called_once_with('{}-{}{}'.format(pathname, i, '.csv'))
            test_wm._result[i].to_excel.assert_called_once_with('{}-{}{}'.format(pathname, i, '.xlsx'))
            test_wm._result[i].to_stata.assert_called_once_with('{}-{}{}'.format(pathname, i, '.dta'))
            test_wm._result[i].to_html.assert_called_once_with('{}-{}{}'.format(pathname, i, '.html'))
예제 #2
0
    def test_table_1(self, mock_fdf):
        '''
        _make_table():

        - "count frequency" is True
        - file extension on "pathname" with period
        '''
        test_wm = WorkflowManager([])
        test_wm.settings(None, 'count frequency', True)  # just to be 100% clear
        mock_fdf.return_value = mock.MagicMock(spec_set=pandas.DataFrame)
        test_wm._result = mock_fdf.return_value  # to avoid a RuntimeError
        test_wm._previous_exp = 'intervals'  # to get the proper "exp_name"
        top_x = None
        threshold = None
        exp_name = 'Interval Frequency'
        pathname = 'test_path'

        test_wm._make_table('CSV', pathname + '.csv', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Excel', pathname + '.xlsx', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('Stata', pathname + '.dta', top_x, threshold)  # pylint: disable=protected-access
        test_wm._make_table('HTML', pathname + '.html', top_x, threshold)  # pylint: disable=protected-access

        mock_fdf.return_value.to_csv.assert_called_once_with('test_path.csv')
        mock_fdf.return_value.to_stata.assert_called_once_with('test_path.dta')
        mock_fdf.return_value.to_excel.assert_called_once_with('test_path.xlsx')
        mock_fdf.return_value.to_html.assert_called_once_with('test_path.html')
        self.assertSequenceEqual([mock.call(top_x=top_x, threshold=threshold, name=exp_name) for _ in range(4)],
                                 mock_fdf.call_args_list)