-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Limit actions on disabled organizations #815
Controller views return 404 response for disabled organizations. Closes #815
- Loading branch information
Showing
5 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from unittest.mock import patch | ||
|
||
from django.test import TestCase | ||
|
||
from openwisp_users.tests.utils import TestOrganizationMixin | ||
|
||
from .. import tasks | ||
|
||
|
||
class TestHandlers(TestOrganizationMixin, TestCase): | ||
@patch.object(tasks.invalidate_device_checksum_view_cache, 'delay') | ||
def test_organization_disabled_handler(self, mocked_task): | ||
with self.subTest('Test task not executed on creating active orgs'): | ||
org = self._create_org() | ||
mocked_task.assert_not_called() | ||
|
||
with self.subTest('Test task executed on changing active to inactive org'): | ||
org.is_active = False | ||
org.save() | ||
mocked_task.assert_called_once() | ||
|
||
mocked_task.reset_mock() | ||
with self.subTest('Test task not executed on saving inactive org'): | ||
org.name = 'Changed named' | ||
org.save() | ||
mocked_task.assert_not_called() | ||
|
||
with self.subTest('Test task not executed on creating inactive org'): | ||
self._create_org(is_active=False, name='inactive', slug='inactive') | ||
mocked_task.assert_not_called() |