Skip to content

Commit b6fda24

Browse files
committed
[fix] Fixed Device._has_group() wrongly returning True
1 parent aa97110 commit b6fda24

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

openwisp_controller/config/base/device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _has_config(self):
128128
return hasattr(self, 'config')
129129

130130
def _has_group(self):
131-
return hasattr(self, 'group')
131+
return hasattr(self, 'group') and self.group is not None
132132

133133
def _has_organization__config_settings(self):
134134
return hasattr(self, 'organization') and hasattr(

openwisp_controller/config/tests/test_device.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,11 @@ def test_device_org_change_limit_check(self):
564564
f' for organization {org2}.'
565565
),
566566
)
567+
568+
def test_has_methods(self):
569+
device = self._create_device(
570+
name='11:22:33:44:55:66',
571+
mac_address='11:22:33:44:55:66',
572+
organization=self._get_org(),
573+
)
574+
self.assertFalse(device._has_group())

0 commit comments

Comments
 (0)