Skip to content

Commit 2e355bd

Browse files
codesankalpnemesifier
authored andcommitted
[tests] Removed operator_permission_filters from tests
Related to openwisp/openwisp-users#106
1 parent e3b3b74 commit 2e355bd

File tree

8 files changed

+1223
-42
lines changed

8 files changed

+1223
-42
lines changed

openwisp_controller/config/tests/test_admin.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ class TestAdmin(
4646
object_model = Device
4747
object_location_model = DeviceLocation
4848
maxDiff = None
49-
operator_permission_filters = [
50-
{'codename__endswith': 'config'},
51-
{'codename__endswith': 'device'},
52-
{'codename__endswith': 'template'},
53-
{'codename__endswith': 'vpn'},
54-
]
5549
_device_params = {
5650
'name': 'test-device',
5751
'hardware_id': '1234',
@@ -197,6 +191,7 @@ def _create_multitenancy_test_env(self, vpn=False):
197191
org2 = self._create_org(name='test2org')
198192
inactive = self._create_org(name='inactive-org', is_active=False)
199193
operator = self._create_operator(organizations=[org1, inactive])
194+
administrator = self._create_administrator(organizations=[org1, inactive])
200195
t1 = self._create_template(name='template1org', organization=org1)
201196
t2 = self._create_template(name='template2org', organization=org2)
202197
t3 = self._create_template(name='t3-inactive', organization=inactive)
@@ -229,6 +224,7 @@ def _create_multitenancy_test_env(self, vpn=False):
229224
org2=org2,
230225
inactive=inactive,
231226
operator=operator,
227+
administrator=administrator,
232228
)
233229
if vpn:
234230
v1 = self._create_vpn(name='vpn1org', organization=org1)
@@ -316,6 +312,7 @@ def test_vpn_organization_fk_queryset(self):
316312
visible=[data['org1'].name],
317313
hidden=[data['org2'].name, data['inactive']],
318314
select_widget=True,
315+
administrator=True,
319316
)
320317

321318
def test_vpn_ca_fk_queryset(self):
@@ -325,6 +322,7 @@ def test_vpn_ca_fk_queryset(self):
325322
visible=[data['vpn1'].ca.name, data['vpn_shared'].ca.name],
326323
hidden=[data['vpn2'].ca.name, data['vpn_inactive'].ca.name],
327324
select_widget=True,
325+
administrator=True,
328326
)
329327

330328
def test_vpn_cert_fk_queryset(self):
@@ -334,6 +332,7 @@ def test_vpn_cert_fk_queryset(self):
334332
visible=[data['vpn1'].cert.name, data['vpn_shared'].cert.name],
335333
hidden=[data['vpn2'].cert.name, data['vpn_inactive'].cert.name],
336334
select_widget=True,
335+
administrator=True,
337336
)
338337

339338
def test_changelist_recover_deleted_button(self):

openwisp_controller/config/tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def test_vpn_create_api(self):
449449
def test_vpn_create_with_shared_objects(self):
450450
org1 = self._get_org()
451451
shared_ca = self._create_ca(name='shared_ca', organization=None)
452-
test_user = self._create_operator(organizations=[org1])
452+
test_user = self._create_administrator(organizations=[org1])
453453
self.client.force_login(test_user)
454454
data = self._get_vpn_data.copy()
455455
data['organization'] = org1.pk
@@ -472,7 +472,7 @@ def test_vpn_list_for_shared_objects(self):
472472
ca = self._create_ca(name='shared_ca', organization=None)
473473
self._create_cert(ca=ca, name='shared_cert', organization=None)
474474
org1 = self._get_org()
475-
test_user = self._create_operator(organizations=[org1])
475+
test_user = self._create_administrator(organizations=[org1])
476476
self.client.force_login(test_user)
477477
path = reverse('config_api:vpn_list')
478478
r = self.client.get(path, {'format': 'api'})

openwisp_controller/connection/tests/test_admin.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
class TestConnectionAdmin(TestAdminMixin, CreateConnectionsMixin, TestCase):
2525
config_app_label = 'config'
2626
app_label = 'connection'
27-
operator_permission_filters = [
28-
{'codename__endswith': 'config'},
29-
{'codename__endswith': 'device'},
30-
{'codename__endswith': 'template'},
31-
{'codename__endswith': 'connection'},
32-
{'codename__endswith': 'credentials'},
33-
{'codename__endswith': 'device_connection'},
34-
]
3527
_device_params = TestConfigAdmin._device_params.copy()
3628

3729
def _get_device_params(self, org):
@@ -44,6 +36,7 @@ def _create_multitenancy_test_env(self):
4436
org2 = self._create_org(name='test2org')
4537
inactive = self._create_org(name='inactive-org', is_active=False)
4638
operator = self._create_operator(organizations=[org1, inactive])
39+
administrator = self._create_administrator(organizations=[org1, inactive])
4740
cred1 = self._create_credentials(organization=org1, name='test1cred')
4841
cred2 = self._create_credentials(organization=org2, name='test2cred')
4942
cred3 = self._create_credentials(organization=inactive, name='test3cred')
@@ -61,6 +54,7 @@ def _create_multitenancy_test_env(self):
6154
org2=org2,
6255
inactive=inactive,
6356
operator=operator,
57+
administrator=administrator,
6458
)
6559
return data
6660

@@ -70,6 +64,7 @@ def test_credentials_queryset(self):
7064
url=reverse(f'admin:{self.app_label}_credentials_changelist'),
7165
visible=[data['cred1'].name, data['org1'].name],
7266
hidden=[data['cred2'].name, data['org2'].name, data['cred3_inactive'].name],
67+
administrator=True,
7368
)
7469

7570
def test_credentials_organization_fk_queryset(self):
@@ -79,6 +74,7 @@ def test_credentials_organization_fk_queryset(self):
7974
visible=[data['org1'].name],
8075
hidden=[data['org2'].name, data['inactive']],
8176
select_widget=True,
77+
administrator=True,
8278
)
8379

8480
def test_connection_queryset(self):
@@ -91,6 +87,7 @@ def test_connection_queryset(self):
9187
data['org2'].name,
9288
data['dc3_inactive'].credentials.name,
9389
],
90+
administrator=True,
9491
)
9592

9693
def test_connection_credentials_fk_queryset(self):

openwisp_controller/geo/tests/test_admin.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ class TestAdmin(TestAdminMixin, TestGeoMixin, BaseTestAdmin, TestCase):
2121
object_location_model = DeviceLocation
2222
user_model = get_user_model()
2323

24-
operator_permission_filters = [
25-
{'codename__endswith': 'config'},
26-
{'codename__endswith': 'device'},
27-
{'codename__endswith': 'template'},
28-
{'codename__endswith': 'vpn'},
29-
{'codename__endswith': 'location'},
30-
{'codename__endswith': 'floorplan'},
31-
{'codename__endswith': 'devicelocation'},
32-
]
33-
3424
def setUp(self):
3525
"""override TestAdminMixin.setUp"""
3626
pass

openwisp_controller/pki/tests/test_admin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
class TestAdmin(TestPkiMixin, TestAdminMixin, TestOrganizationMixin, TestCase):
1515
app_label = 'pki'
1616

17-
operator_permission_filters = [
18-
{'codename__endswith': 'ca'},
19-
{'codename__endswith': 'cert'},
20-
]
21-
2217
def _create_multitenancy_test_env(self, cert=False):
2318
org1 = self._create_org(name='test1org')
2419
org2 = self._create_org(name='test2org')
2520
inactive = self._create_org(name='inactive-org', is_active=False)
2621
operator = self._create_operator(organizations=[org1, inactive])
22+
administrator = self._create_administrator(organizations=[org1, inactive])
2723
ca1 = self._create_ca(name='ca1', organization=org1)
2824
ca2 = self._create_ca(name='ca2', organization=org2)
2925
ca_shared = self._create_ca(name='ca-shared', organization=None)
@@ -37,6 +33,7 @@ def _create_multitenancy_test_env(self, cert=False):
3733
org2=org2,
3834
inactive=inactive,
3935
operator=operator,
36+
administrator=administrator,
4037
)
4138
if cert:
4239
cert1 = self._create_cert(name='cert1', ca=ca1, organization=org1)
@@ -77,6 +74,7 @@ def test_ca_organization_fk_queryset(self):
7774
visible=[data['org1'].name],
7875
hidden=[data['org2'].name, data['inactive']],
7976
select_widget=True,
77+
administrator=True,
8078
)
8179

8280
def test_cert_queryset(self):
@@ -99,6 +97,7 @@ def test_cert_organization_fk_queryset(self):
9997
visible=[data['org1'].name],
10098
hidden=[data['org2'].name, data['inactive']],
10199
select_widget=True,
100+
administrator=True,
102101
)
103102

104103
def test_cert_ca_fk_queryset(self):
@@ -108,6 +107,7 @@ def test_cert_ca_fk_queryset(self):
108107
visible=[data['ca1'].name, data['ca_shared'].name],
109108
hidden=[data['ca2'].name, data['ca_inactive'].name],
110109
select_widget=True,
110+
administrator=True,
111111
)
112112

113113
def test_cert_changeform_200(self):

0 commit comments

Comments
 (0)