Skip to content

Commit

Permalink
Merge pull request #3186 from ammirate/rt_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
david-caro committed Feb 14, 2018
2 parents 60ed2ea + 55cb137 commit 806e6a7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
4 changes: 2 additions & 2 deletions inspirehep/modules/literaturesuggest/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ def curation_ticket_context(user, obj):
arxiv_ids + dois + report_numbers + ['(#{0})'.format(recid)]
))

references = obj.extra_data.get('formdata').get('references')
references = obj.extra_data.get('formdata', {}).get('references')
user_comment = obj.extra_data.get('formdata', {}).get('extra_comments', '')

return dict(
recid=recid,
record_url=record_url,
link_to_pdf=link_to_pdf,
email=user.email,
email=user.email if user else '',
references=references,
user_comment=user_comment,
subject=subject
Expand Down
9 changes: 3 additions & 6 deletions inspirehep/modules/workflows/tasks/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ def create_ticket(template,
@wraps(create_ticket)
def _create_ticket(obj, eng):
user = User.query.get(obj.id_user)
if not user:
obj.log.error(
"No user found for object %s, skipping ticket creation", obj.id)
return

context = {}
if context_factory:
context = context_factory(user, obj)
Expand All @@ -95,7 +92,7 @@ def _create_ticket(obj, eng):
u'To: {requestors} Queue: {queue}'.format(
queue=queue,
subject=context.get('subject'),
requestors=user.email,
requestors=user.email if user else '',
)
)
return
Expand All @@ -106,7 +103,7 @@ def _create_ticket(obj, eng):
queue,
template,
context,
user.email,
user.email if user else '',
recid,
ticket_id_key)

Expand Down
52 changes: 36 additions & 16 deletions tests/integration/workflows/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,33 @@ def workflow_app():
.. deprecated:: 2017-09-18
Use ``app`` instead.
"""
app = create_app(
BEARD_API_URL="http://example.com/beard",
DEBUG=True,
CELERY_ALWAYS_EAGER=True,
CELERY_RESULT_BACKEND='cache',
CELERY_CACHE_BACKEND='memory',
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
PRODUCTION_MODE=True,
LEGACY_ROBOTUPLOAD_URL=(
'http://localhost:1234'
),
MAGPIE_API_URL="http://example.com/magpie",
WORKFLOWS_MATCH_REMOTE_SERVER_URL="http://legacy_search.endpoint/",
WORKFLOWS_FILE_LOCATION="/",
WTF_CSRF_ENABLED=False,
)
RT_URL = "http://rt.inspire"

with requests_mock.Mocker() as m:
m.register_uri(
requests_mock.ANY,
re.compile('.*' + RT_URL + '.*'),
status_code=200,
text='Status 200'
)

app = create_app(
BEARD_API_URL="http://example.com/beard",
DEBUG=True,
CELERY_ALWAYS_EAGER=True,
CELERY_RESULT_BACKEND='cache',
CELERY_CACHE_BACKEND='memory',
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
PRODUCTION_MODE=True,
LEGACY_ROBOTUPLOAD_URL=(
'http://localhost:1234'
),
MAGPIE_API_URL="http://example.com/magpie",
WORKFLOWS_MATCH_REMOTE_SERVER_URL="http://legacy_search.endpoint/",
WORKFLOWS_FILE_LOCATION="/",
WTF_CSRF_ENABLED=False,
CFG_BIBCATALOG_SYSTEM_RT_URL=RT_URL
)

with app.app_context():
yield app
Expand Down Expand Up @@ -130,6 +141,15 @@ def mocked_external_services(workflow_app):
status_code=200,
json={'phonetic_blocks': {}},
)
requests_mocker.register_uri(
requests_mock.ANY,
re.compile(
'.*' +
workflow_app.config['CFG_BIBCATALOG_SYSTEM_RT_URL'] +
'/ticket/new.*'
),
status_code=200,
)

yield

Expand Down

0 comments on commit 806e6a7

Please sign in to comment.