-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11255 from nucleogenesis/enhancement--insufficien…
…t-storage-calc Set insufficient storage DeviceStatus in ContentSyncHook.post_transfer
- Loading branch information
Showing
3 changed files
with
114 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import mock | ||
from morango.sync.context import SessionContext | ||
|
||
from kolibri.core.auth.sync_operations import KolibriSyncOperations | ||
from kolibri.core.content.kolibri_plugin import ContentSyncHook | ||
from kolibri.core.content.test.utils.test_content_request import ( | ||
IncompleteDownloadsQuerysetTestCase, | ||
) | ||
from kolibri.core.device.models import DeviceStatus | ||
|
||
|
||
class KolibriContentSyncHookTestCase(IncompleteDownloadsQuerysetTestCase): | ||
def setUp(self): | ||
super(KolibriContentSyncHookTestCase, self).setUp() | ||
self.operation = KolibriSyncOperations() | ||
self.context = mock.Mock(spec_set=SessionContext)() | ||
|
||
@mock.patch("kolibri.core.device.models.LearnerDeviceStatus.save_learner_status") | ||
@mock.patch("kolibri.core.content.utils.content_request.StorageCalculator") | ||
def test_post_transfer_sets_insufficient_storage( | ||
self, | ||
mock_calc, | ||
mock_save_learner_status, | ||
): | ||
with mock.patch( | ||
"kolibri.core.content.utils.settings.automatic_download_enabled", | ||
return_value=True, | ||
): | ||
with mock.patch( | ||
"kolibri.core.content.utils.content_request.get_free_space_for_downloads", | ||
return_value=0, | ||
): | ||
self._create_resources(self.admin_request.contentnode_id) | ||
hook = ContentSyncHook() | ||
hook.post_transfer( | ||
self.facility.dataset_id, | ||
True, | ||
True, | ||
self.learner.id, | ||
self.context, | ||
) | ||
mock_save_learner_status.assert_called_with( | ||
self.learner.id, DeviceStatus.InsufficientStorage | ||
) |
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