Skip to content

Commit 02d0b13

Browse files
committed
fix more sanctions tests
1 parent 860430b commit 02d0b13

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

api_tests/users/views/test_user_actions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ def test_valid_transitions(
260260
preprint.date_last_transitioned = None
261261
preprint.save()
262262
payload = self.create_payload(preprint._id, trigger=trigger)
263-
with capture_notifications():
263+
if trigger == 'submit':
264+
with capture_notifications():
265+
res = app.post_json_api(url, payload, auth=moderator.auth)
266+
else:
264267
res = app.post_json_api(url, payload, auth=moderator.auth)
265268
assert res.status_code == 201
266-
267269
action = preprint.actions.order_by('-created').first()
268270
assert action.trigger == trigger
269271

osf/models/sanctions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ def _email_template_context(self,
565565
})
566566
else:
567567
context.update({
568+
'domain': osf_settings.DOMAIN,
568569
'user_fullname': user.fullname,
569570
'initiated_by_fullname': self.initiated_by.fullname,
570571
'registration_link': registration_link,
@@ -574,7 +575,9 @@ def _email_template_context(self,
574575
'reviewable_title': self._get_registration().title,
575576
'reviewable__id': self._get_registration()._id,
576577
'reviewable_absolute_url': self._get_registration().absolute_url,
577-
578+
'reviewable_provider_name': self._get_registration().provider.name,
579+
'reviewable_provider__id': self._get_registration().provider._id,
580+
'reviewable_provider': self._get_registration().provider.name,
578581
'reviewable_registered_from_absolute_url': self._get_registration().registered_from.absolute_url,
579582
'reviewable_withdrawal_justification': self._get_registration().withdrawal_justification,
580583
'reviewable_branched_from_node': self._get_registration().branched_from_node
@@ -890,6 +893,7 @@ def _email_template_context(self, user, node, is_authorizer=False, urls=None):
890893
'reviewable_absolute_url': self._get_registration().absolute_url,
891894
'reviewable_branched_from_node': self._get_registration().branched_from_node,
892895
'reviewable_provider_name': self._get_registration().provider.name,
896+
'reviewable_provider__id': self._get_registration().provider._id,
893897
'approval_time_span': approval_time_span,
894898
'reviewable_registered_from_absolute_url': self._get_registration().registered_from.absolute_url,
895899
})
@@ -1054,6 +1058,7 @@ def _email_template_context(self, user, node, is_authorizer=False, urls=None):
10541058
})
10551059
else:
10561060
context.update({
1061+
'domain': osf_settings.DOMAIN,
10571062
'initiated_by_fullname': self.initiated_by.fullname,
10581063
'project_name': self.target_registration.title,
10591064
'registration_link': registration_link,

osf_tests/test_node.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ def test_template_has_no_parent(self, template):
421421
assert template.parent_node is None
422422

423423
def test_template_has_correct_affiliations(self, user, auth, project_with_affiliations):
424-
template = project_with_affiliations.use_as_template(auth=auth)
424+
with capture_notifications():
425+
template = project_with_affiliations.use_as_template(auth=auth)
425426
user_affiliations = user.get_institution_affiliations().values_list('institution__id', flat=True)
426427
project_affiliations = project_with_affiliations.affiliated_institutions.values_list('id', flat=True)
427428
template_affiliations = template.affiliated_institutions.values_list('id', flat=True)
@@ -4187,7 +4188,8 @@ def test_template_security(self, user, auth, project, pointee, component, subpro
41874188
visible_nodes = [x for x in project.nodes if x.can_view(other_user_auth)]
41884189

41894190
# create templated node
4190-
new = project.use_as_template(auth=other_user_auth)
4191+
with capture_notifications():
4192+
new = project.use_as_template(auth=other_user_auth)
41914193

41924194
assert new.title == self._default_title(project)
41934195

osf_tests/test_sanctions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ def test_moderated_sanction__no_identifier_created_until_moderator_approval(self
214214
provider.get_group('moderator').user_set.add(moderator)
215215

216216
# Admin approval
217-
registration.sanction.accept()
217+
with capture_notifications():
218+
registration.sanction.accept()
218219
assert not registration.get_identifier(category='doi')
219220

220221
# Moderator approval

tests/test_registrations/test_retractions.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,17 @@ def test_valid_POST_retraction_adds_to_parent_projects_log(self):
877877
assert self.registration.registered_from.logs.count() == initial_project_logs + 1
878878

879879
def test_valid_POST_retraction_when_pending_retraction_raises_400(self):
880-
self.app.post(
881-
self.retraction_post_url,
882-
json={'justification': ''},
883-
auth=self.user.auth,
884-
)
885-
res = self.app.post(
886-
self.retraction_post_url,
887-
json={'justification': ''},
888-
auth=self.user.auth,
889-
)
880+
with capture_notifications():
881+
self.app.post(
882+
self.retraction_post_url,
883+
json={'justification': ''},
884+
auth=self.user.auth,
885+
)
886+
res = self.app.post(
887+
self.retraction_post_url,
888+
json={'justification': ''},
889+
auth=self.user.auth,
890+
)
890891
assert res.status_code == 400
891892

892893
def test_valid_POST_calls_send_mail_with_username(self):

website/templates/pending_embargo_admin.html.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
% if is_moderated:
1818
If approved by all admin contributors, the registration will be submitted for moderator review.
1919
If the moderators approve, the registration will be embargoed until
20-
${embargo_end_date.date()}, at which time it will be made public as part of the
20+
${embargo_end_date}, at which time it will be made public as part of the
2121
<a href="${domain}/registries/${reviewable_provider__id if reviewable_provider__id else 'osf'}">${reviewable_provider_name if reviewable_provider__id else "OSF Registry"}</a>.
2222
% else:
2323
If approved by all admin contributors, the registration will be embargoed until
24-
${embargo_end_date.date()}, at which point it will be made public as part of the
24+
${embargo_end_date}, at which point it will be made public as part of the
2525
<a href="${domain}/registries/${reviewable_provider__id if reviewable_provider__id else 'osf'}">${reviewable_provider_name if reviewable_provider__id else "OSF Registry"}</a>.
2626
% endif
2727
</p>

0 commit comments

Comments
 (0)