Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions openwisp_controller/config/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,8 @@ def _get_delete_btn_html(self, device):
'Delete</a></p>'
)

_deactivated_device_expected_readonly_fields = 22

def test_device_with_config_change_deactivate_deactivate(self):
"""
This test checks the following things
Expand Down Expand Up @@ -2229,7 +2231,7 @@ def test_device_with_config_change_deactivate_deactivate(self):
self.assertContains(
response,
'<div class="readonly">',
22,
self._deactivated_device_expected_readonly_fields,
)
# Save buttons are absent on deactivated device
self.assertNotContains(response, self._save_btn_html)
Expand Down Expand Up @@ -2311,10 +2313,13 @@ def _test_device_changelist_activate_deactivate_admin_action(
f' was {html_method}ed successfully.</li>'
)
multiple_success_message_html = (
f'<li class="success">The following devices were {html_method}ed'
f' successfully: <a href="/admin/config/device/{device1.id}/change/">'
f'{device1.name}</a>, <a href="/admin/config/device/{device2.id}/change/">'
f'{device2.name}</a> and <a href="/admin/config/device/{device3.id}/'
f'<li class="success">The following devices were {html_method}ed '
'successfully: '
f'<a href="/admin/{self.app_label}/device/{device1.id}/change/">'
f'{device1.name}</a>, '
f'<a href="/admin/{self.app_label}/device/{device2.id}/change/">'
f'{device2.name}</a> and '
f'<a href="/admin/{self.app_label}/device/{device3.id}/'
f'change/">{device3.name}</a>.</li>'
)
single_error_message_html = (
Expand Down
17 changes: 17 additions & 0 deletions tests/openwisp2/sample_config/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
from openwisp_controller.config.tests.test_admin import (
TestDeviceGroupAdmin as BaseTestDeviceGroupAdmin,
)
from openwisp_controller.config.tests.test_admin import (
TestDeviceGroupAdminTransaction as BaseTestDeviceGroupAdminTransaction,
)
from openwisp_controller.config.tests.test_admin import (
TestTransactionAdmin as BaseTestTransactionAdmin,
)
from openwisp_controller.config.tests.test_api import TestConfigApi as BaseTestConfigApi
from openwisp_controller.config.tests.test_apps import TestApps as BaseTestApps
from openwisp_controller.config.tests.test_config import TestConfig as BaseTestConfig
Expand Down Expand Up @@ -38,10 +44,19 @@ class TestAdmin(BaseTestAdmin):
app_label = 'sample_config'


class TestTransactionAdmin(BaseTestTransactionAdmin):
app_label = 'sample_config'
_deactivated_device_expected_readonly_fields = 23


class TestDeviceGroupAdmin(BaseTestDeviceGroupAdmin):
app_label = 'sample_config'


class TestDeviceGroupAdminTransaction(BaseTestDeviceGroupAdminTransaction):
app_label = 'sample_config'


class TestConfig(BaseTestConfig):
pass

Expand Down Expand Up @@ -107,7 +122,9 @@ class TestVxlan(BaseTestVxlan):


del BaseTestAdmin
del BaseTestTransactionAdmin
del BaseTestDeviceGroupAdmin
del BaseTestDeviceGroupAdminTransaction
del BaseTestConfig
del BaseTestTransactionConfig
del BaseTestController
Expand Down
Loading