1010
1111from django .conf import settings
1212from django .core .urlresolvers import reverse as urlreverse
13+ from django .core .urlresolvers import NoReverseMatch
1314
1415from ietf .doc .models import Document , DocAlias , DocEvent , State
1516from ietf .group .models import Group , GroupEvent , GroupMilestone , GroupStateTransitions , MilestoneGroupEvent
1617from ietf .group .utils import save_group_in_history
17- from ietf .name .models import DocTagName , GroupStateName
18+ from ietf .name .models import DocTagName , GroupStateName , GroupTypeName
1819from ietf .person .models import Person , Email
1920from ietf .utils .test_utils import TestCase
2021from ietf .utils .mail import outbox
@@ -48,11 +49,37 @@ def test_active_groups(self):
4849 url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = "rg" ))
4950 r = self .client .get (url )
5051 self .assertEqual (r .status_code , 200 )
52+ self .assertTrue ('Active Research Groups' in r .content )
5153
5254 url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = "area" ))
5355 r = self .client .get (url )
5456 self .assertEqual (r .status_code , 200 )
55- self .assertTrue ("farfut" in r .content )
57+ self .assertTrue ("Far Future (farfut)" in r .content )
58+
59+ url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = "ag" ))
60+ r = self .client .get (url )
61+ self .assertEqual (r .status_code , 200 )
62+ self .assertTrue ("Active Area Groups" in r .content )
63+
64+ url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = "dir" ))
65+ r = self .client .get (url )
66+ self .assertEqual (r .status_code , 200 )
67+ self .assertTrue ("Active Directorates" in r .content )
68+
69+ url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = "team" ))
70+ r = self .client .get (url )
71+ self .assertEqual (r .status_code , 200 )
72+ self .assertTrue ("Active Teams" in r .content )
73+
74+ url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict ())
75+ r = self .client .get (url )
76+ self .assertEqual (r .status_code , 200 )
77+ self .assertTrue ("Directorate" in r .content )
78+ self .assertTrue ("AG" in r .content )
79+
80+ for slug in GroupTypeName .objects .exclude (slug__in = ['wg' ,'rg' ,'ag' ,'area' ,'dir' ,'team' ]).values_list ('slug' ,flat = True ):
81+ with self .assertRaises (NoReverseMatch ):
82+ url = urlreverse ('ietf.group.info.active_groups' , kwargs = dict (group_type = slug ))
5683
5784 def test_wg_summaries (self ):
5885 draft = make_test_data ()
@@ -195,14 +222,17 @@ def test_group_charter(self):
195222 due = datetime .date .today () + datetime .timedelta (days = 100 ))
196223 milestone .docs .add (draft )
197224
198- url = group .about_url ()
199- r = self .client .get (url )
200- self .assertEqual (r .status_code , 200 )
201- self .assertTrue (group .name in r .content )
202- self .assertTrue (group .acronym in r .content )
203- self .assertTrue ("This is a charter." in r .content )
204- self .assertTrue (milestone .desc in r .content )
205- self .assertTrue (milestone .docs .all ()[0 ].name in r .content )
225+ for url in [group .about_url (),
226+ urlreverse ('ietf.group.info.group_about' ,kwargs = dict (acronym = group .acronym )),
227+ urlreverse ('ietf.group.info.group_about' ,kwargs = dict (acronym = group .acronym ,group_type = group .type_id )),
228+ ]:
229+ r = self .client .get (url )
230+ self .assertEqual (r .status_code , 200 )
231+ self .assertTrue (group .name in r .content )
232+ self .assertTrue (group .acronym in r .content )
233+ self .assertTrue ("This is a charter." in r .content )
234+ self .assertTrue (milestone .desc in r .content )
235+ self .assertTrue (milestone .docs .all ()[0 ].name in r .content )
206236
207237 def test_group_about (self ):
208238 make_test_data ()
@@ -214,12 +244,16 @@ def test_group_about(self):
214244 state_id = "active" ,
215245 )
216246
217- url = group .about_url ()
218- r = self .client .get (url )
219- self .assertEqual (r .status_code , 200 )
220- self .assertTrue (group .name in r .content )
221- self .assertTrue (group .acronym in r .content )
222- self .assertTrue (group .description in r .content )
247+ for url in [group .about_url (),
248+ urlreverse ('ietf.group.info.group_about' ,kwargs = dict (acronym = group .acronym )),
249+ urlreverse ('ietf.group.info.group_about' ,kwargs = dict (acronym = group .acronym ,group_type = group .type_id )),
250+ ]:
251+ url = group .about_url ()
252+ r = self .client .get (url )
253+ self .assertEqual (r .status_code , 200 )
254+ self .assertTrue (group .name in r .content )
255+ self .assertTrue (group .acronym in r .content )
256+ self .assertTrue (group .description in r .content )
223257
224258 def test_materials (self ):
225259 make_test_data ()
@@ -235,11 +269,15 @@ def test_materials(self):
235269 doc .set_state (State .objects .get (type = "slides" , slug = "active" ))
236270 DocAlias .objects .create (name = doc .name , document = doc )
237271
238- url = urlreverse ("group_materials" , kwargs = { 'acronym' : group .acronym })
239- r = self .client .get (url )
240- self .assertEqual (r .status_code , 200 )
241- self .assertTrue (doc .title in r .content )
242- self .assertTrue (doc .name in r .content )
272+ for url in [ urlreverse ("group_materials" , kwargs = { 'acronym' : group .acronym }),
273+ urlreverse ("group_materials" , kwargs = { 'acronym' : group .acronym , 'group_type' : group .type_id }),
274+ ]:
275+ r = self .client .get (url )
276+ self .assertEqual (r .status_code , 200 )
277+ self .assertTrue (doc .title in r .content )
278+ self .assertTrue (doc .name in r .content )
279+
280+ url = urlreverse ("group_materials" , kwargs = { 'acronym' : group .acronym })
243281
244282 # try deleting the document and check it's gone
245283 doc .set_state (State .objects .get (type = "slides" , slug = "deleted" ))
@@ -475,6 +513,19 @@ def test_edit_info(self):
475513 self .assertEqual (group .groupurl_set .all ()[0 ].name , "MARS site" )
476514 self .assertTrue (os .path .exists (os .path .join (self .charter_dir , "%s-%s.txt" % (group .charter .canonical_name (), group .charter .rev ))))
477515
516+ def test_initial_charter (self ):
517+ make_test_data ()
518+ group = Group .objects .get (acronym = "mars" )
519+ for url in [ urlreverse ('ietf.group.edit.submit_initial_charter' , kwargs = {'acronym' :group .acronym }),
520+ urlreverse ('ietf.group.edit.submit_initial_charter' , kwargs = {'acronym' :group .acronym ,'group_type' :group .type_id }),
521+ ]:
522+ login_testing_unauthorized (self , "secretary" , url )
523+ r = self .client .get (url ,follow = True )
524+ self .assertEqual (r .status_code ,200 )
525+ self .assertTrue (r .redirect_chain [0 ][0 ].endswith (urlreverse ('charter_submit' ,kwargs = {'name' :group .charter .name ,'option' :'initcharter' })))
526+ self .client .logout ()
527+
528+
478529 def test_conclude (self ):
479530 make_test_data ()
480531
@@ -998,11 +1049,13 @@ def setUp(self):
9981049 def tearDown (self ):
9991050 os .unlink (self .group_alias_file .name )
10001051
1001- def testNothing (self ):
1002- url = urlreverse ('ietf.group.info.email_aliases' , kwargs = dict (acronym = "mars" ))
1003- r = self .client .get (url )
1004- self .assertTrue (all ([x in r .content for x in ['mars-ads@' ,'mars-chairs@' ]]))
1005- self .assertFalse (any ([x in r .content for x in ['ames-ads@' ,'ames-chairs@' ]]))
1052+ def testEmailAliases (self ):
1053+
1054+ for testdict in [dict (acronym = "mars" ),dict (acronym = "mars" ,group_type = "wg" )]:
1055+ url = urlreverse ('ietf.group.info.email_aliases' , kwargs = testdict )
1056+ r = self .client .get (url )
1057+ self .assertTrue (all ([x in r .content for x in ['mars-ads@' ,'mars-chairs@' ]]))
1058+ self .assertFalse (any ([x in r .content for x in ['ames-ads@' ,'ames-chairs@' ]]))
10061059
10071060 url = urlreverse ('ietf.group.info.email_aliases' , kwargs = dict ())
10081061 login_testing_unauthorized (self , "plain" , url )
0 commit comments