Skip to content

Commit 0a08bb1

Browse files
committed
[fix] Fixed tests
1 parent cc29d7c commit 0a08bb1

File tree

7 files changed

+21
-16
lines changed

7 files changed

+21
-16
lines changed

openwisp_controller/geo/apps.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from openwisp_utils.admin_theme import register_dashboard_chart
1616
from openwisp_utils.admin_theme.menu import register_menu_group
1717

18-
from ..config import settings as config_app_settings
1918
from .estimated_location.handlers import (
2019
register_estimated_location_notification_types,
2120
whois_fetched_handler,
@@ -64,16 +63,15 @@ def connect_receivers(self):
6463
sender=self.org_geo_settings_model,
6564
dispatch_uid="invalidate_org_geo_settings_cache_on_delete",
6665
)
67-
if config_app_settings.WHOIS_CONFIGURED:
68-
# connect estimated location handler to whois_fetched signal
69-
whois_fetched.connect(
70-
whois_fetched_handler,
71-
dispatch_uid="whois_fetched_estimated_location_handler",
72-
)
73-
whois_lookup_skipped.connect(
74-
whois_lookup_skipped_handler,
75-
dispatch_uid="whois_lookup_skipped_estimated_location_handler",
76-
)
66+
# connect estimated location handler to whois_fetched signal
67+
whois_fetched.connect(
68+
whois_fetched_handler,
69+
dispatch_uid="whois_fetched_estimated_location_handler",
70+
)
71+
whois_lookup_skipped.connect(
72+
whois_lookup_skipped_handler,
73+
dispatch_uid="whois_lookup_skipped_estimated_location_handler",
74+
)
7775

7876
def _add_params_to_test_config(self):
7977
"""

openwisp_controller/geo/estimated_location/service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from openwisp_controller.config import settings as config_app_settings
99
from openwisp_controller.config.whois.utils import send_whois_task_notification
1010

11-
from .. import settings as geo_settings
12-
1311
logger = logging.getLogger(__name__)
1412

1513

openwisp_controller/geo/estimated_location/tests/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_estimated_location_configuration_setting(self):
9393
response, 'name="geo_settings-0-estimated_location_enabled"'
9494
)
9595

96+
@mock.patch.object(config_app_settings, "WHOIS_CONFIGURED", True)
9697
def test_organization_geo_settings_validation(self):
9798
"""Test OrganizationGeoSettings model validation."""
9899
org = self._get_org()

openwisp_controller/geo/estimated_location/tests/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def setUp(self):
2121
# Ensure OrganizationGeoSettings exists (signals usually create it on
2222
# Organization creation, but make this explicit to avoid RelatedObject
2323
# errors in some test setups).
24-
org_geo_settings, _ = OrganizationGeoSettings.objects.get_or_create(organization=org)
24+
org_geo_settings, _ = OrganizationGeoSettings.objects.get_or_create(
25+
organization=org
26+
)
2527
org_geo_settings.estimated_location_enabled = True
2628
org_geo_settings.save()
2729

openwisp_controller/geo/migrations/0006_create_geo_settings_for_existing_orgs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
from django.db import migrations
44

5-
from . import assign_geo_settings_permissions_to_groups
65
from ...migrations import get_swapped_model
6+
from . import assign_geo_settings_permissions_to_groups
7+
78

89
def create_geo_settings_for_existing_orgs(apps, schema_editor):
910
"""

openwisp_controller/geo/tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _create_organization(self, **kwargs):
2121

2222
def _add_default_org(self, kwargs):
2323
if "organization" not in kwargs:
24-
kwargs["organization"] = self._get_org()
24+
kwargs["organization"] = self._create_organization()
2525
return kwargs
2626

2727
def _create_object(self, **kwargs):

openwisp_controller/tests/mixins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def _get_org_edit_form_inline_params(self, user, org):
1111
"config_settings-INITIAL_FORMS": 0,
1212
"config_settings-MIN_NUM_FORMS": 0,
1313
"config_settings-MAX_NUM_FORMS": 0,
14+
# geo inline
15+
"geo_settings-TOTAL_FORMS": 0,
16+
"geo_settings-INITIAL_FORMS": 0,
17+
"geo_settings-MIN_NUM_FORMS": 0,
18+
"geo_settings-MAX_NUM_FORMS": 0,
1419
# device limit inline
1520
"config_limits-TOTAL_FORMS": 0,
1621
"config_limits-INITIAL_FORMS": 0,

0 commit comments

Comments
 (0)