Skip to content

Commit ccf380c

Browse files
authored
[tests] Added missing sample_config admin tests
1 parent 5400a27 commit ccf380c

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

openwisp_controller/config/tests/test_admin.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,8 @@ def _get_delete_btn_html(self, device):
21902190
'Delete</a></p>'
21912191
)
21922192

2193+
_deactivated_device_expected_readonly_fields = 22
2194+
21932195
def test_device_with_config_change_deactivate_deactivate(self):
21942196
"""
21952197
This test checks the following things
@@ -2229,7 +2231,7 @@ def test_device_with_config_change_deactivate_deactivate(self):
22292231
self.assertContains(
22302232
response,
22312233
'<div class="readonly">',
2232-
22,
2234+
self._deactivated_device_expected_readonly_fields,
22332235
)
22342236
# Save buttons are absent on deactivated device
22352237
self.assertNotContains(response, self._save_btn_html)
@@ -2311,10 +2313,13 @@ def _test_device_changelist_activate_deactivate_admin_action(
23112313
f' was {html_method}ed successfully.</li>'
23122314
)
23132315
multiple_success_message_html = (
2314-
f'<li class="success">The following devices were {html_method}ed'
2315-
f' successfully: <a href="/admin/config/device/{device1.id}/change/">'
2316-
f'{device1.name}</a>, <a href="/admin/config/device/{device2.id}/change/">'
2317-
f'{device2.name}</a> and <a href="/admin/config/device/{device3.id}/'
2316+
f'<li class="success">The following devices were {html_method}ed '
2317+
'successfully: '
2318+
f'<a href="/admin/{self.app_label}/device/{device1.id}/change/">'
2319+
f'{device1.name}</a>, '
2320+
f'<a href="/admin/{self.app_label}/device/{device2.id}/change/">'
2321+
f'{device2.name}</a> and '
2322+
f'<a href="/admin/{self.app_label}/device/{device3.id}/'
23182323
f'change/">{device3.name}</a>.</li>'
23192324
)
23202325
single_error_message_html = (

tests/openwisp2/sample_config/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
from openwisp_controller.config.tests.test_admin import (
33
TestDeviceGroupAdmin as BaseTestDeviceGroupAdmin,
44
)
5+
from openwisp_controller.config.tests.test_admin import (
6+
TestDeviceGroupAdminTransaction as BaseTestDeviceGroupAdminTransaction,
7+
)
8+
from openwisp_controller.config.tests.test_admin import (
9+
TestTransactionAdmin as BaseTestTransactionAdmin,
10+
)
511
from openwisp_controller.config.tests.test_api import TestConfigApi as BaseTestConfigApi
612
from openwisp_controller.config.tests.test_apps import TestApps as BaseTestApps
713
from openwisp_controller.config.tests.test_config import TestConfig as BaseTestConfig
@@ -38,10 +44,19 @@ class TestAdmin(BaseTestAdmin):
3844
app_label = 'sample_config'
3945

4046

47+
class TestTransactionAdmin(BaseTestTransactionAdmin):
48+
app_label = 'sample_config'
49+
_deactivated_device_expected_readonly_fields = 23
50+
51+
4152
class TestDeviceGroupAdmin(BaseTestDeviceGroupAdmin):
4253
app_label = 'sample_config'
4354

4455

56+
class TestDeviceGroupAdminTransaction(BaseTestDeviceGroupAdminTransaction):
57+
app_label = 'sample_config'
58+
59+
4560
class TestConfig(BaseTestConfig):
4661
pass
4762

@@ -107,7 +122,9 @@ class TestVxlan(BaseTestVxlan):
107122

108123

109124
del BaseTestAdmin
125+
del BaseTestTransactionAdmin
110126
del BaseTestDeviceGroupAdmin
127+
del BaseTestDeviceGroupAdminTransaction
111128
del BaseTestConfig
112129
del BaseTestTransactionConfig
113130
del BaseTestController

0 commit comments

Comments
 (0)