Browse Source

Add manager delete test.

Return output of super calls.
pull/8213/head
Richard Tibbles 3 months ago
parent
commit
b403ac366c
  1. 6
      kolibri/core/device/models.py
  2. 7
      kolibri/core/device/test/test_device_settings.py

6
kolibri/core/device/models.py

@ -97,12 +97,14 @@ class DeviceSettings(models.Model):
def save(self, *args, **kwargs):
self.pk = 1
self.full_clean()
super(DeviceSettings, self).save(*args, **kwargs)
out = super(DeviceSettings, self).save(*args, **kwargs)
cache.set(DEVICE_SETTINGS_CACHE_KEY, self, 600)
return out
def delete(self, *args, **kwargs):
super(DeviceSettings, self).delete(*args, **kwargs)
out = super(DeviceSettings, self).delete(*args, **kwargs)
cache.delete(DEVICE_SETTINGS_CACHE_KEY)
return out
CONTENT_CACHE_KEY_CACHE_KEY = "content_cache_key"

7
kolibri/core/device/test/test_device_settings.py

@ -31,3 +31,10 @@ class DeviceSettingsTestCase(TestCase):
DeviceSettings.objects.all().delete()
with self.assertRaises(DeviceSettings.DoesNotExist):
DeviceSettings.objects.get()
def test_delete_setting_manager(self):
cache.clear()
DeviceSettings.objects.create()
DeviceSettings.objects.delete()
with self.assertRaises(DeviceSettings.DoesNotExist):
DeviceSettings.objects.get()

Loading…
Cancel
Save