Skip to content

Commit d3bb76e

Browse files
Clean up tests
1 parent fbf38d5 commit d3bb76e

File tree

2 files changed

+1
-202
lines changed

2 files changed

+1
-202
lines changed

api_tests/subscriptions/views/test_subscriptions_list.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ def url(self, user, node):
3434
def test_list_complete(self, app, user, provider, node, global_user_notification, url):
3535
res = app.get(url, auth=user.auth)
3636
notification_ids = [item['id'] for item in res.json['data']]
37-
# There should only be 4 notifications: users' global, node's comments, node's file updates and provider's preprint added.
37+
# There should only be 3 notifications: users' global, node's file updates and provider's preprint added.
3838
assert len(notification_ids) == 3
3939
assert f'{user._id}_global' in notification_ids
4040
assert f'{provider._id}_new_pending_submissions' in notification_ids
41-
assert f'{node._id}_comments' in notification_ids
4241
assert f'{node._id}_file_updated' in notification_ids
4342

4443
def test_unauthenticated(self, app, url):

tests/test_notifications.py

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -429,26 +429,6 @@ def test_from_subscription_key(self):
429429
'event': 'comment_replies'
430430
}
431431

432-
def test_get_all_user_subscriptions(self):
433-
user_subscriptions = list(utils.get_all_user_subscriptions(self.user))
434-
assert self.project_subscription in user_subscriptions
435-
assert self.node_comments_subscription in user_subscriptions
436-
for x in self.user_subscription:
437-
assert x in user_subscriptions
438-
assert len(user_subscriptions) == 6
439-
440-
def test_get_all_node_subscriptions_given_user_subscriptions(self):
441-
user_subscriptions = utils.get_all_user_subscriptions(self.user)
442-
node_subscription_ids = [x._id for x in utils.get_all_node_subscriptions(self.user, self.node,
443-
user_subscriptions=user_subscriptions)]
444-
expected_node_subscription_ids = [x._id for x in self.node_subscription]
445-
assert node_subscription_ids == expected_node_subscription_ids
446-
447-
def test_get_all_node_subscriptions_given_user_and_node(self):
448-
node_subscription_ids = [x._id for x in utils.get_all_node_subscriptions(self.user, self.node)]
449-
expected_node_subscription_ids = [x._id for x in self.node_subscription]
450-
assert node_subscription_ids == expected_node_subscription_ids
451-
452432
def test_get_configured_project_ids_does_not_return_user_or_node_ids(self):
453433
configured_nodes = utils.get_configured_projects(self.user)
454434
configured_ids = [n._id for n in configured_nodes]
@@ -498,171 +478,6 @@ def test_get_configured_project_ids_excludes_private_projects_if_no_subscription
498478
configured_project_nodes = utils.get_configured_projects(user)
499479
assert private_project not in configured_project_nodes
500480

501-
def test_get_parent_notification_type(self):
502-
nt = utils.get_parent_notification_type(self.node, 'comments', self.user)
503-
assert nt == 'email_transactional'
504-
505-
def test_get_parent_notification_type_no_parent_subscriptions(self):
506-
node = factories.NodeFactory()
507-
nt = utils.get_parent_notification_type(node._id, 'comments', self.user)
508-
assert nt is None
509-
510-
def test_get_parent_notification_type_no_parent(self):
511-
project = factories.ProjectFactory()
512-
nt = utils.get_parent_notification_type(project._id, 'comments', self.user)
513-
assert nt is None
514-
515-
def test_get_parent_notification_type_handles_user_id(self):
516-
nt = utils.get_parent_notification_type(self.user._id, 'comments', self.user)
517-
assert nt is None
518-
519-
def test_format_data_project_settings(self):
520-
data = utils.format_data(self.user, [self.project])
521-
parent_event = {
522-
'event': {
523-
'title': 'comments',
524-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
525-
'notificationType': 'email_transactional',
526-
'parent_notification_type': None
527-
},
528-
'kind': 'event',
529-
'children': []
530-
}
531-
child_event = {
532-
'event': {
533-
'title': 'comments',
534-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
535-
'notificationType': 'email_transactional',
536-
'parent_notification_type': 'email_transactional'
537-
},
538-
'kind': 'event',
539-
'children': []
540-
}
541-
expected_new = [['event'], 'event']
542-
schema = subscription_schema(self.project, expected_new)
543-
assert schema.validate(data)
544-
assert has(data, parent_event)
545-
assert has(data, child_event)
546-
547-
def test_format_data_node_settings(self):
548-
data = utils.format_data(self.user, [self.node])
549-
event = {
550-
'event': {
551-
'title': 'comments',
552-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
553-
'notificationType': 'email_transactional',
554-
'parent_notification_type': 'email_transactional'
555-
},
556-
'kind': 'event',
557-
'children': []
558-
}
559-
schema = subscription_schema(self.project, ['event'])
560-
assert schema.validate(data)
561-
assert has(data, event)
562-
563-
def test_format_includes_admin_view_only_component_subscriptions(self):
564-
# Test private components in which parent project admins are not contributors still appear in their
565-
# notifications settings.
566-
node = factories.NodeFactory(parent=self.project)
567-
data = utils.format_data(self.user, [self.project])
568-
event = {
569-
'event': {
570-
'title': 'comments',
571-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
572-
'notificationType': 'adopt_parent',
573-
'parent_notification_type': 'email_transactional'
574-
},
575-
'kind': 'event',
576-
'children': [],
577-
}
578-
schema = subscription_schema(self.project, ['event', ['event'], ['event']])
579-
assert schema.validate(data)
580-
assert has(data, event)
581-
582-
def test_format_data_excludes_pointers(self):
583-
project = factories.ProjectFactory()
584-
pointed = factories.ProjectFactory()
585-
project.add_pointer(pointed, Auth(project.creator))
586-
project.creator.notifications_configured[project._id] = True
587-
project.creator.save()
588-
configured_project_nodes = utils.get_configured_projects(project.creator)
589-
data = utils.format_data(project.creator, configured_project_nodes)
590-
event = {
591-
'event': {
592-
'title': 'comments',
593-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
594-
'notificationType': 'email_transactional',
595-
'parent_notification_type': None
596-
},
597-
'kind': 'event',
598-
'children': [],
599-
}
600-
schema = subscription_schema(self.project, ['event'])
601-
assert schema.validate(data)
602-
assert has(data, event)
603-
604-
def test_format_data_user_subscriptions_includes_private_parent_if_configured_children(self):
605-
private_project = factories.ProjectFactory()
606-
node = factories.NodeFactory(parent=private_project)
607-
608-
node_comments_subscription = factories.NotificationSubscriptionFactory(
609-
_id=node._id + '_' + 'comments',
610-
node=node,
611-
event_name='comments'
612-
)
613-
node_comments_subscription.save()
614-
node_comments_subscription.email_transactional.add(node.creator)
615-
node_comments_subscription.save()
616-
617-
node.creator.notifications_configured[node._id] = True
618-
node.creator.save()
619-
configured_project_nodes = utils.get_configured_projects(node.creator)
620-
data = utils.format_data(node.creator, configured_project_nodes)
621-
event = {
622-
'event': {
623-
'title': 'comments',
624-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
625-
'notificationType': 'email_transactional',
626-
'parent_notification_type': None
627-
},
628-
'kind': 'event',
629-
'children': [],
630-
}
631-
schema = subscription_schema(self.project, ['event', ['event']])
632-
assert schema.validate(data)
633-
assert has(data, event)
634-
635-
def test_format_data_user_subscriptions_if_children_points_to_parent(self):
636-
private_project = factories.ProjectFactory(creator=self.user)
637-
node = factories.NodeFactory(parent=private_project, creator=self.user)
638-
node.save()
639-
node_comments_subscription = factories.NotificationSubscriptionFactory(
640-
_id=node._id + '_' + 'comments',
641-
node=node,
642-
event_name='comments'
643-
)
644-
node_comments_subscription.save()
645-
node_comments_subscription.email_transactional.add(node.creator)
646-
node_comments_subscription.save()
647-
648-
node.creator.notifications_configured[node._id] = True
649-
node.creator.save()
650-
configured_project_nodes = utils.get_configured_projects(node.creator)
651-
data = utils.format_data(node.creator, configured_project_nodes)
652-
event = {
653-
'event': {
654-
'title': 'comments',
655-
'description': constants.NODE_SUBSCRIPTIONS_AVAILABLE['comments'],
656-
'notificationType': 'email_transactional',
657-
'parent_notification_type': None
658-
},
659-
'kind': 'event',
660-
'children': [],
661-
}
662-
schema = subscription_schema(self.project, ['event', ['event']])
663-
assert schema.validate(data)
664-
assert has(data, event)
665-
666481
def test_format_user_subscriptions(self):
667482
data = utils.format_user_subscriptions(self.user)
668483
expected = [
@@ -689,21 +504,6 @@ def test_format_user_subscriptions(self):
689504

690505
assert data == expected
691506

692-
def test_get_global_notification_type(self):
693-
notification_type = utils.get_global_notification_type(self.user_subscription[1] ,self.user)
694-
assert 'email_transactional' == notification_type
695-
696-
# # Business logic prevents this from being an applicable unit test;
697-
# # global_mentions cannot be unsubscribed from
698-
# def test_check_if_all_global_subscriptions_are_none_true(self):
699-
# for x in self.user_subscription:
700-
# x.none.add(self.user)
701-
# x.email_transactional.remove(self.user)
702-
# for x in self.user_subscription:
703-
# x.save()
704-
# all_global_subscriptions_none = utils.check_if_all_global_subscriptions_are_none(self.user)
705-
# assert all_global_subscriptions_none
706-
707507
def test_format_data_user_settings(self):
708508
data = utils.format_user_and_project_subscriptions(self.user)
709509
expected = [

0 commit comments

Comments
 (0)