Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
11d3a3c
[change] Add controller config and connection apps
Nov 28, 2025
706966e
[change] Adjust tests and sample apps
Dec 1, 2025
72e9d2c
[change] Remove sample_config for now
Dec 1, 2025
088a978
Merge branch 'master' into extended_controller_app_tests_part_one
nemesifier Dec 27, 2025
7c1f2a7
[change] Formatting
Dec 29, 2025
df6a7dc
[change] Remove comments and commented accounts/ in tests/openwisp/ur…
Dec 30, 2025
87d9f97
[change] Remove comments regarding config from tests settings
Dec 30, 2025
0aaba03
[change] Simplify sample_connection.tests.TestNotifications
Jan 12, 2026
218ebf5
[change] Merge branch 'master' into extended_controller_app_tests_par…
Mar 4, 2026
4bb164c
[change] Remove unused connection_app_label in test_admin.BaseTestAdmin
Mar 4, 2026
89ce2c3
[change] Merge branch 'master' into extended_controller_app_tests_par…
Mar 10, 2026
7e0468d
[change] Merge branch 'master' into extended_controller_app_tests_par…
asmodehn Jun 2, 2026
11693c6
[change] Update sample_connection app from controller
asmodehn Jun 2, 2026
9d3ad30
[change] Reactivate tests fixes for sample_connection
asmodehn Jun 2, 2026
f5defff
[change] Fix recent test_add_credentials_with_cancelled_upgrade_opera…
asmodehn Jun 2, 2026
357ea15
[change] Cleanup redundant *args in test params
asmodehn Jun 3, 2026
0528c40
[change] Add again TEMPLATES DIRS settings, not related to current ch…
asmodehn Jun 3, 2026
e6c4957
[change] Fix typo in sample_connection.api.views
asmodehn Jun 3, 2026
1680bbc
[change] Add pytest to runtests.py for sample_connection tests
asmodehn Jun 3, 2026
b2e494c
[change] Remove redundant (config_)app_label in sample app tests
asmodehn Jun 3, 2026
d733901
Merge branch 'master' into extended_controller_app_tests_part_one
asmodehn Jun 3, 2026
7a33ac4
[chores] Fix typos after controller update
asmodehn Jun 4, 2026
118c79e
[chores] Run pytest only in sample-app tests
nemesifier Jun 4, 2026
c167fe5
[chores] Handled urls fixes
nemesifier Jun 4, 2026
75c2024
[chores] Minor improvements
nemesifier Jun 4, 2026
ff0cee8
[chores] Removed debugging traces
nemesifier Jun 4, 2026
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
23 changes: 11 additions & 12 deletions openwisp_firmware_upgrader/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def build_list_url(self):

@override_settings(LANGUAGE_CODE="en")
class TestAdmin(BaseTestAdmin, TestCase):
_mock_upgrade = "openwisp_firmware_upgrader.upgraders.openwrt.OpenWrt.upgrade"
_mock_connect = "openwisp_controller.connection.models.DeviceConnection.connect"

def test_build_list(self):
self._login()
build = self._create_build()
Expand Down Expand Up @@ -380,7 +383,7 @@ def test_save_device_with_deleted_devicefirmware(self):
"openwisp_firmware_upgrader.utils.get_upgrader_class_from_device_connection"
)
def test_device_firmware_upgrade_without_device_connection(
self, captured_stderr, mocked_func, *args
self, captured_stderr, mocked_func
):
self._login()
device_fw = self._create_device_firmware()
Expand All @@ -396,7 +399,7 @@ def test_device_firmware_upgrade_without_device_connection(
mocked_func.assert_not_called()
self.assertEqual(response.status_code, 200)

def test_save_device_after_credentials_deleted(self, *args):
def test_save_device_after_credentials_deleted(self):
"""Regression test for #250."""
self._login()
device_fw = self._create_device_firmware(installed=True)
Expand All @@ -420,7 +423,7 @@ def test_save_device_after_credentials_deleted(self, *args):
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "Please correct the error")

def test_change_image_and_add_credentials_together(self, *args):
def test_change_image_and_add_credentials_together(self):
"""Regression test for #250."""
self._login()
device_fw = self._create_device_firmware()
Expand Down Expand Up @@ -461,14 +464,10 @@ def test_change_image_and_add_credentials_together(self, *args):
self.assertEqual(device_fw.image, new_image)
self.assertEqual(device.deviceconnection_set.count(), 1)

def test_add_credentials_with_cancelled_upgrade_operation(self, *args):
def test_add_credentials_with_cancelled_upgrade_operation(self):
"""Regression test for adding credentials while a cancelled upgrade is shown."""
with mock.patch(
"openwisp_controller.connection.models.DeviceConnection.connect",
return_value=True,
), mock.patch(
"openwisp_firmware_upgrader.upgraders.openwrt.OpenWrt.upgrade",
return_value=True,
with mock.patch(self._mock_connect, return_value=True), mock.patch(
self._mock_upgrade, return_value=True
):
self._login()
device = self._create_config(organization=self._get_org()).device
Expand Down Expand Up @@ -569,7 +568,7 @@ def test_deactivated_device_upgrade_operation_readonly(self):
# deactivated devices are readonly
self.assertNotContains(response, 'name="upgradeoperation_set-0-DELETE"')

def test_device_upgrade_shared_firmware(self, *args):
def test_device_upgrade_shared_firmware(self):
org = self._get_org()
administrator = self._create_administrator(organizations=[org])
shared_image = self._create_firmware_image(organization=None)
Expand Down Expand Up @@ -746,7 +745,7 @@ def _get_org_option(org):
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "By organization")

def test_batch_upgrade_operation_filters(self, *args):
def test_batch_upgrade_operation_filters(self):
"""Test that filter UI elements are displayed correctly for organization admin"""
env = self._create_upgrade_env()
org_admin = self._create_administrator(organizations=[env["d1"].organization])
Expand Down
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[pytest]
addopts = -p no:warnings --create-db --reuse-db --nomigrations
DJANGO_SETTINGS_MODULE = openwisp2.settings
python_files = pytest*.py
python_classes = *Test*
pythonpath = tests
log_cli = true
asyncio_mode = strict
asyncio_debug = true
15 changes: 13 additions & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys

import pytest
from django.core.management import execute_from_command_line


Expand All @@ -28,11 +29,21 @@ def run_tests(extra_args, settings_module, test_app):
# Configure Django settings for test execution
# (sets Celery to eager mode, configures in-memory channels layer, etc.)
os.environ.setdefault("TESTING", "1")
args = sys.argv[1:]
args = sys.argv.copy()[1:]
exclude_pytest = "--exclude-pytest" in args
if exclude_pytest:
args.pop(args.index("--exclude-pytest"))
# normal tests vs SAMPLE_APP
if not os.environ.get("SAMPLE_APP", False):
test_app = "openwisp_firmware_upgrader"
app_dir = "openwisp_firmware_upgrader/"
else:
test_app = "openwisp2"
app_dir = "tests/openwisp2/"
# Run Django tests
run_tests(args, "openwisp2.settings", test_app)
django_tests = run_tests(args, "openwisp2.settings", test_app)
# Run pytest tests (only when testing extensions and if not explicltly excluded)
if os.environ.get("SAMPLE_APP", False) and not exclude_pytest:
# Used to test django-channels
sys.exit(pytest.main([app_dir]))
sys.exit(django_tests)
3 changes: 3 additions & 0 deletions tests/media/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!floorplan.jpg
Empty file added tests/media/floorplan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
1 change: 1 addition & 0 deletions tests/openwisp2/sample_connection/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from openwisp_controller.connection import admin # noqa
Empty file.
50 changes: 50 additions & 0 deletions tests/openwisp2/sample_connection/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from openwisp_controller.connection.api.views import (
CommandDetailsView as BaseCommandDetailsView,
)
from openwisp_controller.connection.api.views import (
CommandListCreateView as BaseCommandListCreateView,
)
from openwisp_controller.connection.api.views import (
CredentialDetailView as BaseCredentialDetailView,
)
from openwisp_controller.connection.api.views import (
CredentialListCreateView as BaseCredentialListCreateView,
)
from openwisp_controller.connection.api.views import (
DeviceConnectionDetailView as BaseDeviceConnectionDetailView,
)
from openwisp_controller.connection.api.views import (
DeviceConnectionListCreateView as BaseDeviceConnectionListCreateView,
)


class CommandDetailsView(BaseCommandDetailsView):
pass


class CommandListCreateView(BaseCommandListCreateView):
pass


class CredentialListCreateView(BaseCredentialListCreateView):
pass


class CredentialDetailView(BaseCredentialDetailView):
pass


class DeviceConnectionListCreateView(BaseDeviceConnectionListCreateView):
pass


class DeviceConnectionDetailView(BaseDeviceConnectionDetailView):
pass


command_list_create_view = CommandListCreateView.as_view()
command_details_view = CommandDetailsView.as_view()
credential_list_create_view = CredentialListCreateView.as_view()
credential_detail_view = CredentialDetailView.as_view()
deviceconnection_list_create_view = DeviceConnectionListCreateView.as_view()
deviceconnection_detail_view = DeviceConnectionDetailView.as_view()
9 changes: 9 additions & 0 deletions tests/openwisp2/sample_connection/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from openwisp_controller.connection.apps import ConnectionConfig


class SampleConnectionConfig(ConnectionConfig):
name = "openwisp2.sample_connection"
label = "sample_connection"


del ConnectionConfig
Loading
Loading