Skip to content

Commit 4f652a2

Browse files
fix contibutor added unit tests p1
1 parent 5757d19 commit 4f652a2

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

api_tests/nodes/views/test_node_contributors_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ def test_add_unregistered_contributor_sends_email(
13111311
)
13121312
assert res.status_code == 201
13131313
assert len(notifications['emits']) == 1
1314-
assert notifications['emits'][0]['type'] == NotificationType.Type.NODE_CONTRIBUTOR_ADDED_DEFAULT
1314+
assert notifications['emits'][0]['type'] == NotificationType.Type.USER_INVITE_DEFAULT
13151315

13161316
@mock.patch('website.project.signals.unreg_contributor_added.send')
13171317
def test_add_unregistered_contributor_signal_if_default(
@@ -1333,7 +1333,7 @@ def test_add_unregistered_contributor_signal_if_default(
13331333
)
13341334
assert res.status_code == 201
13351335
assert len(notifications['emits']) == 1
1336-
assert notifications['emits'][0]['type'] == NotificationType.Type.NODE_CONTRIBUTOR_ADDED_DEFAULT
1336+
assert notifications['emits'][0]['type'] == NotificationType.Type.USER_INVITE_DEFAULT
13371337

13381338
def test_add_unregistered_contributor_signal_preprint_email_disallowed(
13391339
self, app, user, url_project_contribs

osf/models/mixins.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,7 @@ def add_unregistered_contributor(
15411541
fullname,
15421542
email,
15431543
auth,
1544+
notification_type=False,
15441545
visible=True,
15451546
permissions=None,
15461547
existing_user=None
@@ -1589,17 +1590,18 @@ def add_unregistered_contributor(
15891590
else:
15901591
raise e
15911592

1592-
from osf.models import AbstractNode, Preprint, DraftRegistration
1593+
if notification_type is None:
1594+
from osf.models import AbstractNode, Preprint, DraftRegistration
15931595

1594-
if isinstance(self, AbstractNode):
1595-
notification_type = NotificationType.Type.USER_INVITE_DEFAULT
1596-
elif isinstance(self, Preprint):
1597-
if self.provider.is_default:
1598-
notification_type = NotificationType.Type.USER_INVITE_OSF_PREPRINT
1599-
else:
1600-
notification_type = NotificationType.Type.PROVIDER_USER_INVITE_PREPRINT
1601-
elif isinstance(self, DraftRegistration):
1602-
notification_type = NotificationType.Type.USER_INVITE_DRAFT_REGISTRATION
1596+
if isinstance(self, AbstractNode):
1597+
notification_type = NotificationType.Type.USER_INVITE_DEFAULT
1598+
elif isinstance(self, Preprint):
1599+
if self.provider.is_default:
1600+
notification_type = NotificationType.Type.USER_INVITE_OSF_PREPRINT
1601+
else:
1602+
notification_type = NotificationType.Type.PROVIDER_USER_INVITE_PREPRINT
1603+
elif isinstance(self, DraftRegistration):
1604+
notification_type = NotificationType.Type.USER_INVITE_DRAFT_REGISTRATION
16031605

16041606
self.add_contributor(
16051607
contributor,

0 commit comments

Comments
 (0)