1111from ietf .community .utils import docs_matching_community_list_rule , community_list_rules_matching_doc
1212from ietf .community .utils import reset_name_contains_index_for_rule
1313import ietf .community .views
14+ from ietf .group .models import Group
1415from ietf .group .utils import setup_default_community_list_for_group
1516from ietf .doc .models import State
1617from ietf .doc .utils import add_state_change_event
1718from ietf .person .models import Person , Email
18- from ietf .utils .test_data import make_test_data
1919from ietf .utils .test_utils import login_testing_unauthorized , TestCase , unicontent
2020from ietf .utils .mail import outbox
21- from ietf .group .factories import GroupFactory
21+ from ietf .doc .factories import WgDraftFactory
22+ from ietf .group .factories import GroupFactory , RoleFactory
2223from ietf .person .factories import PersonFactory
2324
2425class CommunityListTests (TestCase ):
2526 def test_rule_matching (self ):
26- draft = make_test_data ()
27- iesg_state = State .objects .get (type = "draft-iesg" , slug = "lc" )
28- draft .set_state (iesg_state )
27+ plain = PersonFactory (user__username = 'plain' )
28+ ad = Person .objects .get (user__username = 'ad' )
29+ draft = WgDraftFactory (
30+ group__parent = Group .objects .get (acronym = 'farfut' ),
31+ authors = [ad ],
32+ ad = ad ,
33+ shepherd = plain .email (),
34+ states = [('draft-iesg' ,'lc' ),('draft' ,'active' )],
35+ )
2936
3037 clist = CommunityList .objects .create (user = User .objects .get (username = "plain" ))
3138
@@ -66,7 +73,8 @@ def test_rule_matching(self):
6673 self .assertTrue (draft in list (docs_matching_community_list_rule (rule_name_contains )))
6774
6875 def test_view_list (self ):
69- draft = make_test_data ()
76+ PersonFactory (user__username = 'plain' )
77+ draft = WgDraftFactory ()
7078
7179 url = urlreverse (ietf .community .views .view_list , kwargs = { "username" : "plain" })
7280
@@ -88,7 +96,9 @@ def test_view_list(self):
8896 self .assertTrue (draft .name in unicontent (r ))
8997
9098 def test_manage_personal_list (self ):
91- draft = make_test_data ()
99+ PersonFactory (user__username = 'plain' )
100+ ad = Person .objects .get (user__username = 'ad' )
101+ draft = WgDraftFactory (authors = [ad ])
92102
93103 url = urlreverse (ietf .community .views .manage_list , kwargs = { "username" : "plain" })
94104 login_testing_unauthorized (self , "plain" , url )
@@ -152,7 +162,8 @@ def test_manage_personal_list(self):
152162 self .assertTrue (not clist .searchrule_set .filter (rule_type = "author_rfc" ))
153163
154164 def test_manage_group_list (self ):
155- draft = make_test_data ()
165+ draft = WgDraftFactory (group__acronym = 'mars' )
166+ RoleFactory (group__acronym = 'mars' ,name_id = 'chair' ,person = PersonFactory (user__username = 'marschairman' ))
156167
157168 url = urlreverse (ietf .community .views .manage_list , kwargs = { "acronym" : draft .group .acronym })
158169 setup_default_community_list_for_group (draft .group )
@@ -176,7 +187,8 @@ def test_manage_group_list(self):
176187 self .assertEqual (r .status_code , 200 )
177188
178189 def test_track_untrack_document (self ):
179- draft = make_test_data ()
190+ PersonFactory (user__username = 'plain' )
191+ draft = WgDraftFactory ()
180192
181193 url = urlreverse (ietf .community .views .track_document , kwargs = { "username" : "plain" , "name" : draft .name })
182194 login_testing_unauthorized (self , "plain" , url )
@@ -201,7 +213,8 @@ def test_track_untrack_document(self):
201213 self .assertEqual (list (clist .added_docs .all ()), [])
202214
203215 def test_track_untrack_document_through_ajax (self ):
204- draft = make_test_data ()
216+ PersonFactory (user__username = 'plain' )
217+ draft = WgDraftFactory ()
205218
206219 url = urlreverse (ietf .community .views .track_document , kwargs = { "username" : "plain" , "name" : draft .name })
207220 login_testing_unauthorized (self , "plain" , url )
@@ -222,7 +235,8 @@ def test_track_untrack_document_through_ajax(self):
222235 self .assertEqual (list (clist .added_docs .all ()), [])
223236
224237 def test_csv (self ):
225- draft = make_test_data ()
238+ PersonFactory (user__username = 'plain' )
239+ draft = WgDraftFactory ()
226240
227241 url = urlreverse (ietf .community .views .export_to_csv , kwargs = { "username" : "plain" })
228242
@@ -245,7 +259,7 @@ def test_csv(self):
245259 self .assertTrue (draft .name in unicontent (r ))
246260
247261 def test_csv_for_group (self ):
248- draft = make_test_data ()
262+ draft = WgDraftFactory ()
249263
250264 url = urlreverse (ietf .community .views .export_to_csv , kwargs = { "acronym" : draft .group .acronym })
251265
@@ -256,7 +270,8 @@ def test_csv_for_group(self):
256270 self .assertEqual (r .status_code , 200 )
257271
258272 def test_feed (self ):
259- draft = make_test_data ()
273+ PersonFactory (user__username = 'plain' )
274+ draft = WgDraftFactory ()
260275
261276 url = urlreverse (ietf .community .views .feed , kwargs = { "username" : "plain" })
262277
@@ -283,7 +298,7 @@ def test_feed(self):
283298 self .assertTrue ('<entry>' not in unicontent (r ))
284299
285300 def test_feed_for_group (self ):
286- draft = make_test_data ()
301+ draft = WgDraftFactory ()
287302
288303 url = urlreverse (ietf .community .views .feed , kwargs = { "acronym" : draft .group .acronym })
289304
@@ -294,7 +309,8 @@ def test_feed_for_group(self):
294309 self .assertEqual (r .status_code , 200 )
295310
296311 def test_subscription (self ):
297- draft = make_test_data ()
312+ PersonFactory (user__username = 'plain' )
313+ draft = WgDraftFactory ()
298314
299315 url = urlreverse (ietf .community .views .subscription , kwargs = { "username" : "plain" })
300316
@@ -331,7 +347,8 @@ def test_subscription(self):
331347 self .assertEqual (EmailSubscription .objects .filter (community_list = clist , email = email , notify_on = "significant" ).count (), 0 )
332348
333349 def test_subscription_for_group (self ):
334- draft = make_test_data ()
350+ draft = WgDraftFactory (group__acronym = 'mars' )
351+ RoleFactory (group__acronym = 'mars' ,name_id = 'chair' ,person = PersonFactory (user__username = 'marschairman' ))
335352
336353 url = urlreverse (ietf .community .views .subscription , kwargs = { "acronym" : draft .group .acronym })
337354
@@ -344,16 +361,11 @@ def test_subscription_for_group(self):
344361 self .assertEqual (r .status_code , 200 )
345362
346363 def test_notification (self ):
347- draft = make_test_data ()
364+ PersonFactory (user__username = 'plain' )
365+ draft = WgDraftFactory ()
348366
349367 clist = CommunityList .objects .create (user = User .objects .get (username = "plain" ))
350368 clist .added_docs .add (draft )
351- SearchRule .objects .create (
352- community_list = clist ,
353- rule_type = "name_contains" ,
354- state = State .objects .get (type = "draft" , slug = "active" ),
355- text = "test" ,
356- )
357369
358370 EmailSubscription .objects .create (community_list = clist , email = Email .objects .filter (person__user__username = "plain" ).first (), notify_on = "significant" )
359371
0 commit comments