def test_public_report_state_change_error(self): """ Persistent Report should propagate IO errors from PublicReportFileManager """ self.app = Mock() self.logger = Mock(spec=RootLogger) file_manager = PublicReportFileManager(self.logger, '/some/fake/absolute/path') file_manager.write_data = Mock(side_effect=PublicReportIOError('Boom!')) # do not write anything to disk file_manager.get_public_report_path = Mock() PersistentReport.make_report_public( self.reports[0].id, self.reports[0].user_id, file_manager, 'testing data' )
def set_public_report(report_id): """ Client facing method with pretty url to set/uset one report as public """ # in order to move code to the PersistenReport class need to fetch report # data here db_session = db.get_session() try: result_key = db_session.query(PersistentReport.result_key)\ .filter(PersistentReport.id == report_id)\ .one()[0] finally: db_session.close() data = report_result_json(result_key).data # call would throw an exception if report cannot be made public PersistentReport.make_report_public( report_id, current_user.id, g.file_manager, data ) return json_response(message='Update successful')