2323
2424from ietf .community .models import CommunityList
2525from ietf .community .utils import reset_name_contains_index_for_rule
26+ from ietf .doc .factories import WgDraftFactory , CharterFactory
2627from ietf .doc .models import Document , DocAlias , DocEvent , State
2728from ietf .doc .utils_charter import charter_name_for_group
2829from ietf .group .factories import GroupFactory , RoleFactory , GroupEventFactory
2930from ietf .group .models import Group , GroupEvent , GroupMilestone , GroupStateTransitions , Role
30- from ietf .group .utils import save_group_in_history
31+ from ietf .group .utils import save_group_in_history , setup_default_community_list_for_group
3132from ietf .meeting .factories import SessionFactory
3233from ietf .name .models import DocTagName , GroupStateName , GroupTypeName
3334from ietf .person .models import Person , Email
3435from ietf .person .factories import PersonFactory
36+ from ietf .review .factories import ReviewRequestFactory
3537from ietf .utils .mail import outbox , empty_outbox
36- from ietf .utils .test_data import make_test_data , make_review_data
3738from ietf .utils .test_utils import login_testing_unauthorized , TestCase , unicontent , reload_db_objects
3839
3940def group_urlreverse_list (group , viewname ):
@@ -54,8 +55,9 @@ def tearDown(self):
5455 shutil .rmtree (self .charter_dir )
5556
5657 def test_active_groups (self ):
57- draft = make_test_data ()
58- group = draft .group
58+ area = GroupFactory .create (type_id = 'area' )
59+ group = GroupFactory .create (type_id = 'wg' ,parent = area )
60+ RoleFactory (group = group ,name_id = 'ad' ,person = PersonFactory ())
5961
6062 url = urlreverse ('ietf.group.views.active_groups' , kwargs = dict (group_type = "wg" ))
6163 r = self .client .get (url )
@@ -86,8 +88,10 @@ def test_active_groups(self):
8688 url = urlreverse ('ietf.group.views.active_groups' , kwargs = dict (group_type = slug ))
8789
8890 def test_group_home (self ):
89- draft = make_test_data ()
91+ draft = WgDraftFactory ()
9092 group = draft .group
93+ # TODO - move this into GroupFactory
94+ setup_default_community_list_for_group (group )
9195
9296 url_list = group_urlreverse_list (group , 'ietf.group.views.group_home' )
9397 next_list = group_urlreverse_list (group , 'ietf.group.views.group_documents' )
@@ -103,8 +107,9 @@ def test_group_home(self):
103107 self .assertTrue (draft .title in unicontent (r ))
104108
105109 def test_wg_summaries (self ):
106- draft = make_test_data ()
107- group = draft .group
110+ group = CharterFactory (group__type_id = 'wg' ,group__parent = GroupFactory (type_id = 'area' )).group
111+ RoleFactory (group = group ,name_id = 'chair' ,person = PersonFactory ())
112+ RoleFactory (group = group ,name_id = 'ad' ,person = PersonFactory ())
108113
109114 chair = Email .objects .filter (role__group = group , role__name = "chair" )[0 ]
110115
@@ -145,9 +150,7 @@ def test_wg_summaries(self):
145150 self .assertTrue ("This is a charter." in unicontent (r ))
146151
147152 def test_chartering_groups (self ):
148- draft = make_test_data ()
149- group = draft .group
150- group .charter .set_state (State .objects .get (used = True , type = "charter" , slug = "intrev" ))
153+ group = CharterFactory (group__type_id = 'wg' ,group__parent = GroupFactory (type_id = 'area' ),states = [('charter' ,'intrev' )]).group
151154
152155 url = urlreverse ('ietf.group.views.chartering_groups' )
153156 r = self .client .get (url )
@@ -172,10 +175,7 @@ def test_chartering_groups(self):
172175
173176
174177 def test_concluded_groups (self ):
175- draft = make_test_data ()
176- group = draft .group
177- group .state = GroupStateName .objects .get (used = True , slug = "conclude" )
178- group .save ()
178+ group = GroupFactory (state_id = 'conclude' )
179179
180180 url = urlreverse ('ietf.group.views.concluded_groups' )
181181 r = self .client .get (url )
@@ -184,10 +184,7 @@ def test_concluded_groups(self):
184184 self .assertEqual (len (q ('#content a:contains("%s")' % group .acronym )), 1 )
185185
186186 def test_bofs (self ):
187- draft = make_test_data ()
188- group = draft .group
189- group .state_id = "bof"
190- group .save ()
187+ group = GroupFactory (state_id = 'bof' )
191188
192189 url = urlreverse ('ietf.group.views.bofs' , kwargs = dict (group_type = "wg" ))
193190 r = self .client .get (url )
@@ -196,32 +193,10 @@ def test_bofs(self):
196193 self .assertEqual (len (q ('#content a:contains("%s")' % group .acronym )), 1 )
197194
198195 def test_group_documents (self ):
199- draft = make_test_data ()
200- group = draft .group
201-
202- draft2 = Document .objects .create (
203- name = "draft-somebody-mars-test" ,
204- time = datetime .datetime .now (),
205- type_id = "draft" ,
206- title = "Test By Somebody" ,
207- stream_id = "ietf" ,
208- group = Group .objects .get (type = "individ" ),
209- abstract = "Abstract." ,
210- rev = "01" ,
211- pages = 2 ,
212- intended_std_level_id = "ps" ,
213- shepherd = None ,
214- ad = None ,
215- expires = datetime .datetime .now () + datetime .timedelta (days = 10 ),
216- notify = "" ,
217- note = "" ,
218- )
219-
220- draft2 .set_state (State .objects .get (used = True , type = "draft" , slug = "active" ))
221- DocAlias .objects .create (
222- document = draft2 ,
223- name = draft2 .name ,
224- )
196+ group = GroupFactory ()
197+ setup_default_community_list_for_group (group )
198+ draft = WgDraftFactory (group = group )
199+ draft2 = WgDraftFactory (group = group )
225200
226201 clist = CommunityList .objects .get (group = group )
227202 related_docs_rule = clist .searchrule_set .get (rule_type = 'name_contains' )
@@ -249,8 +224,8 @@ def test_group_documents(self):
249224 self .assertTrue (draft2 .name in unicontent (r ))
250225
251226 def test_group_charter (self ):
252- draft = make_test_data ()
253- group = draft . group
227+ group = CharterFactory (). group
228+ draft = WgDraftFactory ( group = group )
254229
255230 with open (os .path .join (self .charter_dir , "%s-%s.txt" % (group .charter .canonical_name (), group .charter .rev )), "w" ) as f :
256231 f .write ("This is a charter." )
@@ -273,10 +248,7 @@ def test_group_charter(self):
273248
274249 def test_group_about (self ):
275250
276- make_test_data ()
277-
278- p = PersonFactory (user__username = 'iab-member' )
279- Group .objects .get (acronym = 'iab' ).role_set .create (name_id = 'member' ,person = p ,email = p .email ())
251+ RoleFactory (group = Group .objects .get (acronym = 'iab' ),name_id = 'member' ,person = PersonFactory (user__username = 'iab-member' ))
280252
281253 interesting_users = [ 'plain' ,'iana' ,'iab-chair' ,'irtf-chair' , 'marschairman' , 'teamchairman' ,'ad' , 'iab-member' , 'secretary' , ]
282254
@@ -341,8 +313,7 @@ def verify_can_edit_group(url, group, username):
341313 verify_cannot_edit_group (url , group , username )
342314
343315 def test_materials (self ):
344- make_test_data ()
345- group = Group .objects .create (type_id = "team" , acronym = "testteam" , name = "Test Team" , state_id = "active" )
316+ group = GroupFactory (type_id = "team" , acronym = "testteam" , name = "Test Team" , state_id = "active" )
346317
347318 doc = Document .objects .create (
348319 name = "slides-testteam-test-slides" ,
@@ -370,8 +341,7 @@ def test_materials(self):
370341 self .assertTrue (doc .title not in unicontent (r ))
371342
372343 def test_history (self ):
373- draft = make_test_data ()
374- group = draft .group
344+ group = GroupFactory ()
375345
376346 e = GroupEvent .objects .create (
377347 group = group ,
@@ -385,8 +355,7 @@ def test_history(self):
385355 self .assertTrue (e .desc in unicontent (r ))
386356
387357 def test_feed (self ):
388- draft = make_test_data ()
389- group = draft .group
358+ group = CharterFactory ().group
390359
391360 ge = GroupEvent .objects .create (
392361 group = group ,
@@ -408,7 +377,7 @@ def test_feed(self):
408377
409378
410379 def test_chair_photos (self ):
411- make_test_data ( )
380+ RoleFactory ( name_id = 'chair' )
412381 url = urlreverse ("ietf.group.views.chair_photos" , kwargs = {'group_type' :'wg' })
413382 r = self .client .get (url )
414383 self .assertEqual (r .status_code , 200 )
@@ -417,7 +386,9 @@ def test_chair_photos(self):
417386 self .assertEqual (len (q ('div.photo-thumbnail img' )), chairs .count ())
418387
419388 def test_wg_photos (self ):
420- make_test_data ()
389+ GroupFactory (acronym = 'mars' )
390+ RoleFactory (name_id = 'chair' )
391+ RoleFactory (name_id = 'secr' )
421392 url = urlreverse ("ietf.group.views.group_photos" , kwargs = {'group_type' :'wg' , 'acronym' :'mars' })
422393 r = self .client .get (url )
423394 self .assertEqual (r .status_code , 200 )
@@ -426,7 +397,6 @@ def test_wg_photos(self):
426397 self .assertEqual (len (q ('div.photo-thumbnail img' )), roles .count ())
427398
428399 def test_group_photos (self ):
429- make_test_data ()
430400 url = urlreverse ("ietf.group.views.group_photos" , kwargs = {'acronym' :'iab' })
431401 r = self .client .get (url )
432402 self .assertEqual (r .status_code , 200 )
@@ -445,7 +415,6 @@ def tearDown(self):
445415 shutil .rmtree (self .charter_dir )
446416
447417 def test_create (self ):
448- make_test_data ()
449418
450419 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (group_type = "wg" , action = "charter" ))
451420 login_testing_unauthorized (self , "secretary" , url )
@@ -504,8 +473,6 @@ def test_create(self):
504473
505474 def test_create_rg (self ):
506475
507- make_test_data ()
508-
509476 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (group_type = "rg" , action = "charter" ))
510477 login_testing_unauthorized (self , "secretary" , url )
511478
@@ -529,12 +496,11 @@ def test_create_rg(self):
529496 self .assertEqual (charter_name_for_group (group ), "charter-irtf-testrg" )
530497
531498 def test_create_based_on_existing_bof (self ):
532- make_test_data ()
533499
534500 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (group_type = "wg" , action = "charter" ))
535501 login_testing_unauthorized (self , "secretary" , url )
536502
537- group = Group . objects . get (acronym = "mars" )
503+ group = GroupFactory (acronym = "mars" , parent = GroupFactory ( type_id = 'area' ) )
538504
539505 # try hijacking area - faulty
540506 r = self .client .post (url , dict (name = "Test" , acronym = group .parent .acronym ))
@@ -563,8 +529,10 @@ def test_create_based_on_existing_bof(self):
563529 self .assertEqual (Group .objects .get (acronym = group .acronym ).name , "Test" )
564530
565531 def test_edit_info (self ):
566- make_test_data ()
567- group = Group .objects .get (acronym = "mars" )
532+ group = GroupFactory (acronym = 'mars' ,parent = GroupFactory (type_id = 'area' ))
533+ CharterFactory (group = group )
534+ RoleFactory (group = group ,name_id = 'chair' ,person__user__email = 'marschairman@ietf.org' )
535+ RoleFactory (group = group ,name_id = 'delegate' ,person__user__email = 'marsdelegate@ietf.org' )
568536
569537 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (group_type = group .type_id , acronym = group .acronym , action = "edit" ))
570538 login_testing_unauthorized (self , "secretary" , url )
@@ -640,8 +608,7 @@ def test_edit_info(self):
640608
641609
642610 def test_edit_field (self ):
643- make_test_data ()
644- group = Group .objects .get (acronym = "mars" )
611+ group = GroupFactory (acronym = "mars" )
645612
646613 # Edit name
647614 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (acronym = group .acronym , action = "edit" , field = "name" ))
@@ -677,9 +644,8 @@ def test_edit_field(self):
677644
678645
679646 def test_edit_reviewers (self ):
680- doc = make_test_data ()
681- review_req = make_review_data (doc )
682- group = review_req .team
647+ group = GroupFactory (type_id = 'dir' ,parent = GroupFactory (type_id = 'area' ))
648+ ReviewRequestFactory (team = group )
683649
684650 url = urlreverse ('ietf.group.views.edit' , kwargs = dict (group_type = group .type_id , acronym = group .acronym , action = "edit" ))
685651 login_testing_unauthorized (self , "secretary" , url )
@@ -711,9 +677,7 @@ def test_edit_reviewers(self):
711677 self .assertTrue ('Personnel change' in outbox [0 ]['Subject' ])
712678
713679 def test_conclude (self ):
714- make_test_data ()
715-
716- group = Group .objects .get (acronym = "mars" )
680+ group = GroupFactory (acronym = "mars" )
717681
718682 url = urlreverse ('ietf.group.views.conclude' , kwargs = dict (group_type = group .type_id , acronym = group .acronym ))
719683 login_testing_unauthorized (self , "secretary" , url )
@@ -741,8 +705,11 @@ def test_conclude(self):
741705 self .assertEqual (group .state_id , "active" )
742706
743707 def test_add_comment (self ):
744- make_test_data ()
745- group = Group .objects .get (acronym = "mars" )
708+ group = GroupFactory (acronym = "mars" ,parent = GroupFactory (type_id = 'area' ))
709+ RoleFactory (group = group ,person = Person .objects .get (user__username = 'ad' ),name_id = 'ad' )
710+ RoleFactory (group = group ,person__user__username = 'marschairman' ,name_id = 'chair' )
711+ RoleFactory (group = group ,person__user__username = 'marssecretary' ,name_id = 'secr' )
712+ RoleFactory (group = group ,person__user__username = 'marsdelegate' ,name_id = 'delegate' )
746713 url = urlreverse ('ietf.group.views.add_comment' , kwargs = dict (acronym = group .acronym ))
747714 empty_outbox ()
748715 for username in ['secretary' ,'ad' ,'marschairman' ,'marssecretary' ,'marsdelegate' ]:
@@ -766,9 +733,11 @@ def test_add_comment(self):
766733
767734class MilestoneTests (TestCase ):
768735 def create_test_milestones (self ):
769- draft = make_test_data ()
770-
771- group = Group .objects .get (acronym = "mars" )
736+ group = GroupFactory (acronym = 'mars' ,parent = GroupFactory (type_id = 'area' ),list_email = 'mars-wg@ietf.org' )
737+ CharterFactory (group = group )
738+ RoleFactory (group = group ,name_id = 'ad' ,person = Person .objects .get (user__username = 'ad' ))
739+ RoleFactory (group = group ,name_id = 'chair' ,person = PersonFactory (user__username = 'marschairman' ))
740+ draft = WgDraftFactory (group = group )
772741
773742 m1 = GroupMilestone .objects .create (id = 1 ,
774743 group = group ,
@@ -1044,9 +1013,8 @@ def test_reset_charter_milestones(self):
10441013
10451014class CustomizeWorkflowTests (TestCase ):
10461015 def test_customize_workflow (self ):
1047- make_test_data ()
10481016
1049- group = Group . objects . get ( acronym = "mars" )
1017+ group = GroupFactory ( )
10501018
10511019 url = urlreverse ('ietf.group.views.customize_workflow' , kwargs = dict (group_type = group .type_id , acronym = group .acronym ))
10521020 login_testing_unauthorized (self , "secretary" , url )
@@ -1115,7 +1083,9 @@ def test_customize_workflow(self):
11151083class EmailAliasesTests (TestCase ):
11161084
11171085 def setUp (self ):
1118- make_test_data ()
1086+ PersonFactory (user__username = 'plain' )
1087+ GroupFactory (acronym = 'mars' ,parent = GroupFactory (type_id = 'area' ))
1088+ GroupFactory (acronym = 'ames' ,parent = GroupFactory (type_id = 'area' ))
11191089 self .group_alias_file = NamedTemporaryFile (delete = False )
11201090 self .group_alias_file .write ("""# Generated by hand at 2015-02-12_16:30:52
11211091virtual.ietf.org anything
@@ -1175,7 +1145,8 @@ def testExpansions(self):
11751145
11761146class AjaxTests (TestCase ):
11771147 def test_group_menu_data (self ):
1178- make_test_data ()
1148+
1149+ GroupFactory (acronym = 'mars' ,parent = Group .objects .get (acronym = 'farfut' ))
11791150
11801151 r = self .client .get (urlreverse ('ietf.group.views.group_menu_data' ))
11811152 self .assertEqual (r .status_code , 200 )
@@ -1331,8 +1302,7 @@ def test_view_status_update_for_meeting(self):
13311302class GroupParentLoopTests (TestCase ):
13321303
13331304 def test_group_parent_loop (self ):
1334- make_test_data ()
1335- mars = Group .objects .get (acronym = "mars" )
1305+ mars = GroupFactory (acronym = "mars" ,parent = Group .objects .get (acronym = 'farfut' ))
13361306 test1 = Group .objects .create (
13371307 type_id = "team" ,
13381308 acronym = "testteam1" ,
0 commit comments