|
26 | 26 |
|
27 | 27 | from openwisp_radius import settings as app_settings |
28 | 28 | from openwisp_radius.api.serializers import ( |
| 29 | + RadiusUserGroupSerializer, |
29 | 30 | RadiusUserSerializer, |
30 | 31 | UserGroupCheckSerializer, |
31 | 32 | ) |
@@ -1397,7 +1398,7 @@ def test_radius_user_group_list(self): |
1397 | 1398 | OrganizationUser.objects.filter( |
1398 | 1399 | user=target_user, organization=org2 |
1399 | 1400 | ).delete() |
1400 | | - self._create_org_user(user=target_user, organization=org2, is_admin=True) |
| 1401 | + self._create_org_user(user=admin_user, organization=org2, is_admin=True) |
1401 | 1402 | response = self.client.post( |
1402 | 1403 | url, |
1403 | 1404 | {"group": str(org2_group.pk)}, |
@@ -1519,6 +1520,11 @@ def test_radius_user_group_detail(self): |
1519 | 1520 | org2_rug.refresh_from_db() |
1520 | 1521 | self.assertEqual(org2_rug.priority, 7) |
1521 | 1522 |
|
| 1523 | + def test_radius_user_group_serializer_without_view_context(self): |
| 1524 | + serializer = RadiusUserGroupSerializer(context={}) |
| 1525 | + self.assertEqual(serializer._user, None) |
| 1526 | + self.assertEqual(serializer.fields["group"].queryset.count(), 0) |
| 1527 | + |
1522 | 1528 |
|
1523 | 1529 | class TestTransactionApi(AcctMixin, ApiTokenMixin, BaseTransactionTestCase): |
1524 | 1530 | def test_user_radius_usage_view(self): |
|
0 commit comments