@@ -520,10 +520,6 @@ def test_organization_radsettings_freeradius_allowed_hosts(self):
520520 "radius_settings-0-id" : radsetting .pk ,
521521 "radius_settings-0-organization" : org .pk ,
522522 "radius_settings-0-password_reset_url" : PASSWORD_RESET_URL ,
523- "notification_settings-TOTAL_FORMS" : 0 ,
524- "notification_settings-INITIAL_FORMS" : 0 ,
525- "notification_settings-MIN_NUM_FORMS" : 0 ,
526- "notification_settings-MAX_NUM_FORMS" : 1 ,
527523 }
528524 )
529525
@@ -606,10 +602,6 @@ def test_organization_radsettings_password_reset_url(self):
606602 "radius_settings-0-id" : radsetting .pk ,
607603 "radius_settings-0-organization" : org .pk ,
608604 "radius_settings-0-password_reset_url" : PASSWORD_RESET_URL ,
609- "notification_settings-TOTAL_FORMS" : 0 ,
610- "notification_settings-INITIAL_FORMS" : 0 ,
611- "notification_settings-MIN_NUM_FORMS" : 0 ,
612- "notification_settings-MAX_NUM_FORMS" : 1 ,
613605 }
614606 )
615607
@@ -1220,10 +1212,6 @@ def test_organization_radsettings_allowed_mobile_prefixes(self):
12201212 "radius_settings-0-id" : radsetting .pk ,
12211213 "radius_settings-0-organization" : org .pk ,
12221214 "radius_settings-0-password_reset_url" : PASSWORD_RESET_URL ,
1223- "notification_settings-TOTAL_FORMS" : 0 ,
1224- "notification_settings-INITIAL_FORMS" : 0 ,
1225- "notification_settings-MIN_NUM_FORMS" : 0 ,
1226- "notification_settings-MAX_NUM_FORMS" : 1 ,
12271215 }
12281216 )
12291217
@@ -1301,10 +1289,6 @@ def test_organization_radsettings_sms_message(self):
13011289 "radius_settings-0-id" : radsetting .pk ,
13021290 "radius_settings-0-organization" : org .pk ,
13031291 "radius_settings-0-password_reset_url" : PASSWORD_RESET_URL ,
1304- "notification_settings-TOTAL_FORMS" : 0 ,
1305- "notification_settings-INITIAL_FORMS" : 0 ,
1306- "notification_settings-MIN_NUM_FORMS" : 0 ,
1307- "notification_settings-MAX_NUM_FORMS" : 1 ,
13081292 "_continue" : True ,
13091293 }
13101294 )
@@ -1511,56 +1495,30 @@ def test_admin_menu_groups(self):
15111495 html = '<div class="mg-dropdown-label">RADIUS </div>'
15121496 self .assertContains (response , html , html = True )
15131497
1498+ def test_radiusbatch_organization_readonly_for_existing_objects (self ):
1499+ """
1500+ Test that organization field is readonly for existing RadiusBatch objects
1501+ """
1502+ batch = self ._create_radius_batch (
1503+ name = "test-batch" , strategy = "prefix" , prefix = "test-prefix"
1504+ )
1505+ url = reverse (f"admin:{ self .app_label } _radiusbatch_change" , args = [batch .pk ])
15141506
1515- class TestRadiusGroupAdmin (BaseTestCase ):
1516- def setUp (self ):
1517- self .organization = self ._create_org ()
1518- self .admin = self ._create_admin ()
1519- self .organization .add_user (self .admin , is_admin = True )
1520- self .client .force_login (self .admin )
1521-
1522- def test_add_radiusgroup_with_inline_check_succeeds (self ):
1523- add_url = reverse ("admin:openwisp_radius_radiusgroup_add" )
1524-
1525- post_data = {
1526- # Main RadiusGroup form
1527- "organization" : self .organization .pk ,
1528- "name" : "test-group-with-inline" ,
1529- "description" : "A test group created with an inline check" ,
1530- # Inline RadiusGroupCheck formset
1531- "radiusgroupcheck_set-TOTAL_FORMS" : "1" ,
1532- "radiusgroupcheck_set-INITIAL_FORMS" : "0" ,
1533- "radiusgroupcheck_set-0-attribute" : "Max-Daily-Session" ,
1534- "radiusgroupcheck_set-0-op" : ":=" ,
1535- "radiusgroupcheck_set-0-value" : "3600" ,
1536- # Inline RadiusGroupReply formset
1537- "radiusgroupreply_set-TOTAL_FORMS" : "1" ,
1538- "radiusgroupreply_set-INITIAL_FORMS" : "0" ,
1539- "radiusgroupreply_set-0-attribute" : "Session-Timeout" ,
1540- "radiusgroupreply_set-0-op" : "=" ,
1541- "radiusgroupreply_set-0-value" : "1800" ,
1542- }
1507+ response = self .client .get (url )
1508+ self .assertEqual (response .status_code , 200 )
1509+
1510+ self .assertContains (response , "readonly" )
1511+ self .assertContains (response , batch .organization .name )
15431512
1544- response = self .client .post (add_url , data = post_data , follow = True )
1513+ def test_radiusbatch_organization_editable_for_new_objects (self ):
1514+ """
1515+ Test that organization field is editable for new RadiusBatch objects
1516+ """
1517+ url = reverse (f"admin:{ self .app_label } _radiusbatch_add" )
15451518
1519+ response = self .client .get (url )
15461520 self .assertEqual (response .status_code , 200 )
1547- final_group_name = f"{ self .organization .slug } -test-group-with-inline"
1548-
1549- self .assertContains (response , "The group" )
1550- self .assertContains (response , f"{ final_group_name } </a>" )
1551- self .assertContains (response , "was added successfully." )
1552-
1553- self .assertTrue (RadiusGroup .objects .filter (name = final_group_name ).exists ())
1554- group = RadiusGroup .objects .get (name = final_group_name )
1555-
1556- self .assertEqual (group .radiusgroupcheck_set .count (), 1 )
1557- check = group .radiusgroupcheck_set .first ()
1558- self .assertEqual (check .attribute , "Max-Daily-Session" )
1559- self .assertEqual (check .value , "3600" )
1560- self .assertEqual (check .groupname , group .name )
1561-
1562- self .assertEqual (group .radiusgroupreply_set .count (), 1 )
1563- reply = group .radiusgroupreply_set .first ()
1564- self .assertEqual (reply .attribute , "Session-Timeout" )
1565- self .assertEqual (reply .value , "1800" )
1566- self .assertEqual (reply .groupname , group .name )
1521+
1522+ self .assertContains (response , 'name="organization"' )
1523+ form_html = response .content .decode ()
1524+ self .assertIn ('name="organization"' , form_html )
0 commit comments