def test_problems_writing(self): """ Exception is thrown when we cannot write to the directory """ self.file_manager.write_data = Mock(side_effect=PublicReportIOError('Boom!')) wr = WriteReportTask('12345', date.today(), self.results, self.file_manager) wr.run()
def test_happy_case(self): """ Create a report on disk """ today = date.today() concatenated_report_filepath = os.path.join(self.fake_path, COALESCED_REPORT_FILE) wr = WriteReportTask('123', today, self.results, self.file_manager) wr.run() assert_equals(self.file_manager.write_data.call_count, 2) assert_equals(self.file_manager.get_public_report_path.call_count, 1) assert_equals(self.file_manager.coalesce_recurrent_reports.call_count, 1) assert_equals(self.file_manager.remove_old_report_files.call_count, 1) self.file_manager.write_data.assert_called_with(concatenated_report_filepath, json_string(self.results))
def test_no_problems_writing(self): """ Exception is thrown when we pass a bad created date """ wr = WriteReportTask('12345', '', self.results) wr.run()