1+ from unittest import mock
2+
13from tests .base import OsfTestCase
24from osf_tests .factories import ProjectFactory
35
46from osf .models import Node
5- from website .settings import NEW_AND_NOTEWORTHY_LINKS_NODE
67
78from scripts import populate_new_and_noteworthy_projects as script
89
10+ TEST_NEW_AND_NOTEWORTHY_GUID = 'nguid'
11+
912
1013class TestPopulateNewAndNoteworthy (OsfTestCase ):
1114
1215 def setUp (self ):
1316 super ().setUp ()
1417
1518 self .new_and_noteworthy_links_node = ProjectFactory ()
16- self .new_and_noteworthy_links_node ._id = NEW_AND_NOTEWORTHY_LINKS_NODE
19+ self .new_and_noteworthy_links_node ._id = TEST_NEW_AND_NOTEWORTHY_GUID
1720 self .new_and_noteworthy_links_node .save ()
1821
19- self .nn1 = ProjectFactory (is_public = True )
20- self .nn2 = ProjectFactory (is_public = True )
21- self .nn3 = ProjectFactory (is_public = True )
22- self .nn4 = ProjectFactory (is_public = True )
23- self .nn5 = ProjectFactory (is_public = True )
22+ self .nn1 = ProjectFactory (is_public = True , title = 'Noteworthy Alpha' )
23+ self .nn2 = ProjectFactory (is_public = True , title = 'Noteworthy Bravo' )
24+ self .nn3 = ProjectFactory (is_public = True , title = 'Noteworthy Charlie' )
25+ self .nn4 = ProjectFactory (is_public = True , title = 'Noteworthy Foxtrot' )
26+ self .nn5 = ProjectFactory (is_public = True , title = 'Noteworthy Golf' )
2427
2528 self .all_ids = {self .nn1 ._id , self .nn2 ._id , self .nn3 ._id , self .nn4 ._id , self .nn5 ._id }
2629
@@ -32,6 +35,7 @@ def test_get_new_and_noteworthy_nodes(self):
3235 new_noteworthy = script .get_new_and_noteworthy_nodes (self .new_and_noteworthy_links_node )
3336 assert set (new_noteworthy ) == self .all_ids
3437
38+ @mock .patch .object (script , 'NEW_AND_NOTEWORTHY_LINKS_NODE' , TEST_NEW_AND_NOTEWORTHY_GUID )
3539 def test_populate_new_and_noteworthy (self ):
3640 assert self .new_and_noteworthy_links_node ._nodes .count () == 0
3741
0 commit comments