Skip to content

Commit 6816040

Browse files
author
John Tordoff
committed
update tests
1 parent 698ce5d commit 6816040

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

osf_tests/management_commands/test_withdraw_all_preprints_from_provider.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from osf.management.commands.withdraw_all_preprints_from_provider import withdraw_all_preprints
44
from osf_tests.factories import PreprintProviderFactory, PreprintFactory, AuthUserFactory
5+
from tests.utils import capture_notifications
6+
57

68
@pytest.mark.django_db
79
class TestWithdrawAllPreprint:
@@ -23,7 +25,8 @@ def withdrawing_user(self):
2325
return AuthUserFactory()
2426

2527
def test_withdraw_all_preprints(self, preprint_provider, provider_preprint, withdrawing_user):
26-
withdraw_all_preprints(preprint_provider._id, 10, withdrawing_user._id, 'test_comment')
28+
with capture_notifications():
29+
withdraw_all_preprints(preprint_provider._id, 10, withdrawing_user._id, 'test_comment')
2730
provider_preprint.reload()
2831

2932
assert provider_preprint.is_retracted

osf_tests/metadata/test_osf_gathering.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from osf.metrics.utils import YearMonth
3030
from osf.utils import permissions, workflows
3131
from osf_tests import factories
32+
from tests.utils import capture_notifications
3233
from website import settings as website_settings
3334
from website.project import new_bookmark_collection
3435
from osf_tests.metadata._utils import assert_triples
@@ -562,8 +563,9 @@ def test_gather_affiliated_institutions(self):
562563
institution = factories.InstitutionFactory()
563564
institution_iri = URIRef(institution.ror_uri)
564565
self.user__admin.add_or_update_affiliated_institution(institution)
565-
self.project.add_affiliated_institution(institution, self.user__admin)
566-
self.preprint.add_affiliated_institution(institution, self.user__admin)
566+
with capture_notifications():
567+
self.project.add_affiliated_institution(institution, self.user__admin)
568+
self.preprint.add_affiliated_institution(institution, self.user__admin)
567569
assert_triples(osf_gathering.gather_affiliated_institutions(self.projectfocus), {
568570
(self.projectfocus.iri, OSF.affiliation, institution_iri),
569571
(institution_iri, RDF.type, DCTERMS.Agent),
@@ -693,11 +695,12 @@ def test_gather_collection_membership(self):
693695
reviews_workflow='post-moderation',
694696
)
695697
_collection = factories.CollectionFactory(provider=_collection_provider)
696-
osfdb.CollectionSubmission.objects.create(
697-
guid=self.project.guids.first(),
698-
collection=_collection,
699-
creator=self.project.creator,
700-
)
698+
with capture_notifications():
699+
osfdb.CollectionSubmission.objects.create(
700+
guid=self.project.guids.first(),
701+
collection=_collection,
702+
creator=self.project.creator,
703+
)
701704
_collection_ref = rdflib.URIRef(
702705
f'{website_settings.DOMAIN}collections/{_collection_provider._id}',
703706
)

osf_tests/test_elastic_search.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ def test_collection_submission_doc_structure(self):
292292
assert docs[0]['_source']['category'] == 'collectionSubmission'
293293

294294
def test_search_updated_after_id_change(self):
295-
self.provider.primary_collection.collect_object(self.node_one, self.node_one.creator)
295+
with capture_notifications():
296+
self.provider.primary_collection.collect_object(self.node_one, self.node_one.creator)
296297
with run_celery_tasks():
297298
self.node_one.save()
298299
term = f'provider:{self.provider._id}'
@@ -501,7 +502,8 @@ def test_unsubmitted_preprint_primary_file(self):
501502
def test_publish_preprint(self):
502503
title = 'Date'
503504
self.preprint = factories.PreprintFactory(creator=self.user, is_published=False, title=title)
504-
self.preprint.set_published(True, auth=Auth(self.preprint.creator), save=True)
505+
with capture_notifications():
506+
self.preprint.set_published(True, auth=Auth(self.preprint.creator), save=True)
505507
assert self.preprint.title == title
506508
docs = query(title)['results']
507509
# Both preprint and primary_file showing up in Elastic
@@ -1344,7 +1346,9 @@ def test_migration_collections(self):
13441346
collection_one = factories.CollectionFactory(is_public=True, provider=provider)
13451347
collection_two = factories.CollectionFactory(is_public=True, provider=provider)
13461348
node = factories.NodeFactory(creator=self.user, title='Ali Bomaye', is_public=True)
1347-
collection_one.collect_object(node, self.user)
1349+
1350+
with capture_notifications():
1351+
collection_one.collect_object(node, self.user)
13481352
collection_two.collect_object(node, self.user)
13491353
assert node.collection_submissions.filter(
13501354
machine_state=CollectionSubmissionStates.ACCEPTED

osf_tests/test_guid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
)
2121
from tests.base import OsfTestCase
2222
from tests.test_websitefiles import TestFile
23+
from tests.utils import capture_notifications
2324
from website.settings import MFR_SERVER_URL, WATERBUTLER_URL
2425

2526

@@ -312,7 +313,8 @@ def test_resolve_guid_download_file_from_emberapp_preprints_unpublished(self):
312313
# test_provider_submitter_can_download_unpublished
313314
submitter = AuthUserFactory()
314315
pp = PreprintFactory(finish=True, provider=provider, is_published=False, creator=submitter)
315-
pp.run_submit(submitter)
316+
with capture_notifications():
317+
pp.run_submit(submitter)
316318
pp_branded = PreprintFactory(finish=True, provider=branded_provider, is_published=False, filename='preprint_file_two.txt', creator=submitter)
317319
pp_branded.run_submit(submitter)
318320

0 commit comments

Comments
 (0)