def _create_ticket(obj, eng): user = User.query.get(obj.id_user) context = {} if context_factory: context = context_factory(user, obj) if not in_production_mode(): obj.log.info(u'Was going to create ticket: {subject}\n' u'To: {requestors} Queue: {queue}'.format( queue=queue, subject=context.get('subject'), requestors=user.email if user else '', )) return {} recid = obj.extra_data.get("recid") or obj.data.get("control_number") new_ticket_id = submit_rt_ticket(obj, queue, template, context, user.email if user else '', recid, ticket_id_key) return {ticket_id_key: new_ticket_id}
def test_in_production_mode_returns_false_when_variable_is_falsy(): config = {'PRODUCTION_MODE': False} with patch.dict(current_app.config, config): assert not in_production_mode()
def test_in_production_mode_returns_false_when_variable_does_not_exist(): config = {} with patch.dict(current_app.config, config, clear=True): assert not in_production_mode()
def test_in_production_mode(): config = {'PRODUCTION_MODE': True} with patch.dict(current_app.config, config): assert in_production_mode()
def wait_webcoll(obj, eng): if not in_production_mode(): obj.log.debug("Would have wait for webcoll callback.") return eng.halt("Waiting for webcoll.")
def _send_robotupload(obj, eng): combined_callback_url = '' if callback_url: combined_callback_url = os.path.join( current_app.config["SERVER_NAME"], callback_url) if not combined_callback_url.startswith('http'): combined_callback_url = "https://{0}".format( combined_callback_url) if extra_data_key is not None: data = obj.extra_data.get(extra_data_key) or {} else: data = obj.data if not current_app.config.get( 'FEATURE_FLAG_ENABLE_SENDING_REFERENCES_TO_LEGACY'): data = copy(data) data.pop('references', None) marcxml = record2marcxml(data) if current_app.debug: # Log what we are sending LOGGER.debug( "Going to robotupload mode:%s to url:%s:\n%s\n", mode, url, marcxml, ) if not in_production_mode(): obj.log.debug( "Going to robotupload %s to %s:\n%s\n", mode, url, marcxml, ) obj.log.debug("Base object data:\n%s", pformat(data)) return priority = 5 if priority_config_key: priority = current_app.config.get(priority_config_key, priority) result = make_robotupload_marcxml( url=url, marcxml=marcxml, callback_url=combined_callback_url, mode=mode, nonce=obj.id, priority=priority, ) if "[INFO]" not in result.text: if "cannot use the service" in result.text: # IP not in the list obj.log.error( "Your IP is not in " "app.config_BATCHUPLOADER_WEB_ROBOT_RIGHTS " "on host: %s", result.text) txt = "Error while submitting robotupload: {0}".format(result.text) raise Exception(txt) else: obj.log.info("Robotupload sent!") obj.log.info(result.text) if callback_url: eng.halt("Waiting for robotupload: {0}".format(result.text)) obj.log.info("end of upload")
def test_in_production_mode_returns_false_when_variable_is_falsy(): assert not in_production_mode()
def test_in_production_mode_returns_false_when_variable_does_not_exist(): assert not in_production_mode()
def test_in_production_mode(): assert in_production_mode()