Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions tests/test_registrations/test_review_flows.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest
import pytest_socket

from api.providers.workflows import Workflows
from framework.exceptions import PermissionsError
Expand Down Expand Up @@ -98,11 +97,8 @@ def test_approval_flow(self, sanction_object, initial_state, end_state):
assert registration.sanction._id == sanction_object._id

approval_token = sanction_object.token_for_user(registration.creator, 'approval')
try:
with capture_notifications(allow_none=True):
sanction_object.approve(user=registration.creator, token=approval_token)
except pytest_socket.SocketConnectBlockedError:
with capture_notifications():
sanction_object.approve(user=registration.creator, token=approval_token)

registration.refresh_from_db()
assert registration.moderation_state == end_state.db_name
Expand Down Expand Up @@ -137,11 +133,8 @@ def test_rejection_flow(self, sanction_object, initial_state, end_state):
assert registration.sanction._id == sanction_object._id

rejection_token = sanction_object.token_for_user(registration.creator, 'rejection')
try:
with capture_notifications(allow_none=True):
sanction_object.reject(user=registration.creator, token=rejection_token)
except pytest_socket.SocketConnectBlockedError:
with capture_notifications():
sanction_object.reject(user=registration.creator, token=rejection_token)

assert sum([val['has_rejected'] for val in sanction_object.approval_state.values()]) == 1
registration.refresh_from_db()
Expand Down Expand Up @@ -266,10 +259,7 @@ def test_approval_flow(
registration.refresh_from_db()
assert registration.moderation_state == intermediate_state.db_name

try:
with capture_notifications():
sanction_object.accept(user=moderator)
except AssertionError:
with capture_notifications(allow_none=True):
sanction_object.accept(user=moderator)

registration.refresh_from_db()
Expand Down Expand Up @@ -347,10 +337,7 @@ def test_moderator_rejection_flow(
registration.refresh_from_db()
assert registration.moderation_state == intermediate_state.db_name

try:
with capture_notifications():
sanction_object.reject(user=moderator)
except AssertionError:
with capture_notifications(allow_none=True):
sanction_object.reject(user=moderator)

registration.refresh_from_db()
Expand Down Expand Up @@ -844,11 +831,8 @@ def test_approval(self, pending_registration, child_registration, grandchild_reg
assert child_registration.moderation_state == pending_registration.moderation_state
assert grandchild_registration.moderation_state == pending_registration.moderation_state

try:
with capture_notifications(allow_none=True):
pending_registration.sanction.accept()
except pytest_socket.SocketConnectBlockedError:
with capture_notifications():
pending_registration.sanction.accept()

# verify that all registrations have updated state
for reg in [pending_registration, child_registration, grandchild_registration]:
Expand Down
Loading