Skip to content

Commit

Permalink
Merge pull request #335 from EBI-Metagenomics/Hotfix/Disabling-ENA-Co…
Browse files Browse the repository at this point in the history
…nsent-Ticket-Creation

put a fix to prevent consent rt queues from being created
  • Loading branch information
mberacochea authored Nov 8, 2023
2 parents 103568d + d8c1f42 commit da13657
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
9 changes: 2 additions & 7 deletions emgena/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,13 @@ def is_valid(self):
return super().is_valid()

def create(self, validated_data):
"""Create an RT ticket.
If this is a consent approval then the procedure is:
- create ticket in ENA-MG queue
otherwise:
- create ticket in EMG queue
"""Create an RT ticket in EMG queue
Note: remember to setup valid credentials (i.e. url, user and token token) in the config.rt
"""
import requests
n = ena_models.Notify(**validated_data)

emg_queue = settings.RT["emg_queue"]
ena_queue = settings.RT["ena_queue"]

ticket = {
"Requestor": n.from_email,
Expand All @@ -104,7 +99,7 @@ def create(self, validated_data):
ticket["Cc"] = n.cc

if n.is_consent:
ticket["Queue"] = ena_queue
return 404
else:
ticket["Queue"] = emg_queue

Expand Down
36 changes: 0 additions & 36 deletions tests/webuploader/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,6 @@ def test_notify_not_consent(self):
HTTP_AUTHORIZATION='Bearer {}'.format(self.get_token())
)

assert len(responses.calls) == 1
call = responses.calls[0]
assert call.request.url == settings.RT["url"]
assert call.request.body == json.dumps(expected_body)

@responses.activate
@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6 or higher")
def test_notify_consent(self):
"""Test notify endpoint for consent requests
"""
expected_body = {
"Requestor": "[email protected]",
"Priority": "4",
"Subject": "Test email subject",
"Content": "Hi this is just an example",
"Queue": settings.RT["ena_queue"],
}

responses.add(
responses.POST,
settings.RT["url"],
status=200)

post_data = {
"from_email": "[email protected]",
"subject": "Test email subject",
"message": "Hi this is just an example",
"is_consent": True
}

self.client.post(
reverse('emgapi_v1:csrf-notify'),
data=post_data, format='json',
HTTP_AUTHORIZATION='Bearer {}'.format(self.get_token())
)

assert len(responses.calls) == 1
call = responses.calls[0]
assert call.request.url == settings.RT["url"]
Expand Down

0 comments on commit da13657

Please sign in to comment.