Skip to content

Commit 5d0b6b4

Browse files
author
John Tordoff
committed
fix more test stuff
1 parent 6733701 commit 5d0b6b4

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

api_tests/preprints/views/test_preprint_contributors_list.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,22 +1502,21 @@ def test_publishing_preprint_sends_emails_to_contributors(
15021502
url = f'/{API_BASE}preprints/{preprint_unpublished._id}/'
15031503
user_two = AuthUserFactory()
15041504
preprint_unpublished.add_contributor(user_two, permissions=permissions.WRITE, save=True)
1505-
with capture_notifications():
1506-
with capture_signals() as mock_signal:
1507-
with assert_notification(type=NotificationType.Type.PROVIDER_REVIEWS_SUBMISSION_CONFIRMATION, user=user):
1508-
res = app.patch_json_api(
1509-
url,
1510-
{
1511-
'data': {
1512-
'id': preprint_unpublished._id,
1513-
'type': 'preprints',
1514-
'attributes': {
1515-
'is_published': True
1516-
}
1505+
with capture_signals() as mock_signal:
1506+
with assert_notification(type=NotificationType.Type.PROVIDER_REVIEWS_SUBMISSION_CONFIRMATION, user=user):
1507+
res = app.patch_json_api(
1508+
url,
1509+
{
1510+
'data': {
1511+
'id': preprint_unpublished._id,
1512+
'type': 'preprints',
1513+
'attributes': {
1514+
'is_published': True
15171515
}
1518-
},
1519-
auth=user.auth
1520-
)
1516+
}
1517+
},
1518+
auth=user.auth
1519+
)
15211520
assert res.status_code == 200
15221521
assert contributor_added in mock_signal.signals_sent()
15231522
assert mock_update.called

osf/models/schema_response.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ def _notify_users(self, event, event_initiator):
474474
if self.state is ApprovalStates.PENDING_MODERATION:
475475
email_context = notifications.get_email_template_context(resource=self.parent)
476476
email_context['revision_id'] = self._id
477+
email_context['requester_contributor_names'] = ''.join(
478+
self.guid.referent.contributors.values_list('fullname', flat=True)),
477479
reviews_email_submit_moderators_notifications.send(
478480
timestamp=timezone.now(),
479481
context=email_context,

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def assert_emails(mailhog_messages, notifications):
413413
expected_reciver.append(item['kwargs']['user'].username)
414414
expected = _render_email_html(
415415
NotificationType.objects.get(name=item['type']),
416-
item['context']
416+
item['kwargs']['event_context']
417417
)
418418

419419
expected_html.append(normalize(expected).rstrip('\n'))

0 commit comments

Comments
 (0)