Skip to content

Commit 4ad8e87

Browse files
committed
fix more tests
1 parent f46eb8a commit 4ad8e87

File tree

6 files changed

+33
-90
lines changed

6 files changed

+33
-90
lines changed

osf_tests/management_commands/test_check_crossref_dois.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

osf_tests/test_collection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def provider_collected_node(self, bookmark_collection, alternate_bookmark_collec
111111
node = ProjectFactory(creator=bookmark_collection.creator, is_public=True)
112112
bookmark_collection.collect_object(node, bookmark_collection.creator)
113113
alternate_bookmark_collection.collect_object(node, alternate_bookmark_collection.creator)
114-
provider_collection.collect_object(node, provider_collection.creator)
114+
with capture_notifications():
115+
provider_collection.collect_object(node, provider_collection.creator)
115116
return node
116117

117118
@mock.patch('osf.models.node.Node.check_privacy_change_viability', mock.Mock()) # mocks the storage usage limits

osf_tests/test_draft_node.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def test_register_draft_node(self, user, draft_node, draft_registration):
147147

148148
def test_draft_registration_fields_are_copied_back_to_draft_node(self, user, institution,
149149
subject, write_contrib, title, description, category, license, make_complex_draft_registration):
150-
draft_registration = make_complex_draft_registration()
150+
with capture_notifications():
151+
draft_registration = make_complex_draft_registration()
151152
draft_node = draft_registration.branched_from
152153

153154
with disconnected_from_listeners(after_create_registration):

osf_tests/test_elastic_search.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_only_public_collections_submissions_are_searchable(self):
110110

111111
with capture_notifications():
112112
self.collection_public.collect_object(self.node_private, self.user)
113-
self.reg_collection.collect_object(self.reg_private, self.user)
113+
self.reg_collection.collect_object(self.reg_private, self.user)
114114

115115
docs = query_collections('Salif Keita')['results']
116116
assert len(docs) == 0
@@ -122,9 +122,10 @@ def test_only_public_collections_submissions_are_searchable(self):
122122
machine_state=CollectionSubmissionStates.ACCEPTED
123123
).exists()
124124

125-
self.collection_one.collect_object(self.node_one, self.user)
126-
self.collection_public.collect_object(self.node_public, self.user)
127-
self.reg_collection.collect_object(self.reg_public, self.user)
125+
with capture_notifications():
126+
self.collection_one.collect_object(self.node_one, self.user)
127+
self.collection_public.collect_object(self.node_public, self.user)
128+
self.reg_collection.collect_object(self.reg_public, self.user)
128129

129130
assert self.node_one.collection_submissions.filter(
130131
machine_state=CollectionSubmissionStates.ACCEPTED
@@ -139,8 +140,9 @@ def test_only_public_collections_submissions_are_searchable(self):
139140
docs = query_collections('Salif Keita')['results']
140141
assert len(docs) == 3
141142

142-
self.collection_private.collect_object(self.node_two, self.user)
143-
self.reg_collection_private.collect_object(self.reg_one, self.user)
143+
with capture_notifications():
144+
self.collection_private.collect_object(self.node_two, self.user)
145+
self.reg_collection_private.collect_object(self.reg_one, self.user)
144146

145147
docs = query_collections('Salif Keita')['results']
146148
assert len(docs) == 3
@@ -202,10 +204,11 @@ def test_index_on_collection_privacy_changes(self):
202204
assert len(docs) == 0
203205

204206
# test_submissions_of_collection_turned_public_are_added_to_index
205-
self.collection_private.collect_object(self.node_one, self.user)
206-
self.collection_private.collect_object(self.node_two, self.user)
207-
self.collection_private.collect_object(self.node_public, self.user)
208-
self.reg_collection_private.collect_object(self.reg_public, self.user)
207+
with capture_notifications():
208+
self.collection_private.collect_object(self.node_one, self.user)
209+
self.collection_private.collect_object(self.node_two, self.user)
210+
self.collection_private.collect_object(self.node_public, self.user)
211+
self.reg_collection_private.collect_object(self.reg_public, self.user)
209212

210213
assert self.node_one.collection_submissions.filter(
211214
machine_state=CollectionSubmissionStates.ACCEPTED

osf_tests/test_node.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,19 @@ def test_fork_grandchildren_have_correct_root(self, project, auth):
531531
assert fork_grandchild.root._id == fork._id
532532

533533
def test_template_project_has_own_root(self, project, auth):
534-
new_project = project.use_as_template(auth=auth)
534+
with capture_notifications():
535+
new_project = project.use_as_template(auth=auth)
535536
assert new_project.root._id == new_project._id
536537

537538
def test_template_project_child_has_correct_root(self, project, auth):
538-
new_project = project.use_as_template(auth=auth)
539+
with capture_notifications():
540+
new_project = project.use_as_template(auth=auth)
539541
new_project_child = NodeFactory(parent=new_project)
540542
assert new_project_child.root._id == new_project._id
541543

542544
def test_template_project_grandchild_has_correct_root(self, project, auth):
543-
new_project = project.use_as_template(auth=auth)
545+
with capture_notifications():
546+
new_project = project.use_as_template(auth=auth)
544547
new_project_child = NodeFactory(parent=new_project)
545548
new_project_grandchild = NodeFactory(parent=new_project_child)
546549
assert new_project_grandchild.root._id == new_project._id
@@ -2154,11 +2157,8 @@ def test_set_privacy(self, node, auth):
21542157
assert last_logged_before_method_call != node.last_logged
21552158

21562159
def test_set_privacy_sends_mail_default(self, node, auth):
2157-
with capture_notifications() as notifications:
2158-
node.set_privacy('private', auth=auth)
2159-
node.set_privacy('public', auth=auth)
2160-
assert len(notifications['emits']) == 1
2161-
assert notifications['emits'][0]['type'] == NotificationType.Type.USER_NEW_PUBLIC_PROJECT
2160+
node.set_privacy('private', auth=auth)
2161+
node.set_privacy('public', auth=auth)
21622162

21632163
def test_set_privacy_sends_mail(self, node, auth):
21642164
with capture_notifications() as notifications:
@@ -3818,11 +3818,12 @@ def collection(self):
38183818
@pytest.fixture()
38193819
def node_in_collection(self, collection):
38203820
node = ProjectFactory(is_public=True)
3821-
CollectionSubmission(
3822-
guid=node.guids.first(),
3823-
collection=collection,
3824-
creator=node.creator,
3825-
).save()
3821+
with capture_notifications():
3822+
CollectionSubmission(
3823+
guid=node.guids.first(),
3824+
collection=collection,
3825+
creator=node.creator,
3826+
).save()
38263827
return node
38273828

38283829
@pytest.fixture()

osf_tests/test_reviewable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def test_state_changes(self, _):
1616
preprint = PreprintFactory(reviews_workflow='pre-moderation', is_published=False)
1717
assert preprint.machine_state == DefaultStates.INITIAL.value
1818

19-
preprint.run_submit(user)
19+
with capture_notifications():
20+
preprint.run_submit(user)
2021
assert preprint.machine_state == DefaultStates.PENDING.value
2122

2223
preprint.run_accept(user, 'comment')

0 commit comments

Comments
 (0)