def __init__(self, report_id, created, results, file_manager=None): """ TODO: Add dependency injection for the file_manager, we are passing it on the constructor for easier testing but the object should come from the application context Parameters: report_id : identifier of the report, needed to find directory to write to if report is recurrent created : date report was created, used to identify a single run of a recurrent report results : data to write to disk file_manager: PublicReportFileManager, adding to constructor for easy testing. """ self.report_id = report_id self.created_string = format_date_for_public_report_file(created) self.results = json_string(results) self.file_manager = file_manager or PublicReportFileManager( task_logger, get_absolute_path()) # there should not be a need to call these functions more than once self.path = self.file_manager.get_public_report_path(self.report_id, recurrent=True, create=True) # TODO use file manager to get function when function is available self.filepath = os.path.join(self.path, self.created_string)
def __init__(self, report_id, created, results, file_manager=None): """ TODO: Add dependency injection for the file_manager, we are passing it on the constructor for easier testing but the object should come from the application context Parameters: report_id : identifier of the report, needed to find directory to write to if report is recurrent created : date report was created, used to identify a single run of a recurrent report results : data to write to disk file_manager: PublicReportFileManager, adding to constructor for easy testing. """ self.report_id = report_id self.created_string = format_date_for_public_report_file(created) self.results = json_string(results) self.file_manager = file_manager or PublicReportFileManager(task_logger, get_absolute_path()) # there should not be a need to call these functions more than once self.path = self.file_manager.get_public_report_path(self.report_id, recurrent=True, create=True) # TODO use file manager to get function when function is available self.filepath = os.path.join(self.path, self.created_string)
def setUp(self): # setup mock logger self.logger = Mock(spec=RootLogger) self.api = PublicReportFileManager(self.logger, './wikimetrics/') self.test_report_path = os.path.join(get_absolute_path(), os.pardir, 'tests')
def setUp(self): DatabaseTest.setUp(self) self.test_report_path = os.path.join(get_absolute_path(), os.pardir, 'tests')