def test_delete_if_cache_disabled(self): # As above, but without the cache checks self.assertEqual(SiteConfiguration.objects.count(), 0) one_cfg = SiteConfiguration.get_solo() one_cfg.site_name = 'TEST (uncached) SITE PLEASE IGNORE' one_cfg.save() self.assertEqual(SiteConfiguration.objects.count(), 1) one_cfg.delete() self.assertEqual(SiteConfiguration.objects.count(), 0) self.assertEqual(SiteConfiguration.get_solo().site_name, 'Default Config')
def test_delete_if_cache_enabled(self): self.assertEqual(SiteConfiguration.objects.count(), 0) self.assertIsNone(self.cache.get(self.cache_key)) one_cfg = SiteConfiguration.get_solo() one_cfg.site_name = 'TEST SITE PLEASE IGNORE' one_cfg.save() self.assertEqual(SiteConfiguration.objects.count(), 1) self.assertIsNotNone(self.cache.get(self.cache_key)) one_cfg.delete() self.assertEqual(SiteConfiguration.objects.count(), 0) self.assertIsNone(self.cache.get(self.cache_key)) self.assertEqual(SiteConfiguration.get_solo().site_name, 'Default Config')
def setUp(self): self.template = Template( '{% load solo_tags %}' '{% get_solo "tests.SiteConfiguration" as site_config %}' '{{ site_config.site_name }}') self.cache = get_cache('default') self.cache_key = SiteConfiguration.get_cache_key() self.cache.clear() SiteConfiguration.objects.all().delete()
def setUp(self): self.template = Template( '{% load solo_tags %}' '{% get_solo "tests.SiteConfiguration" as site_config %}' '{{ site_config.site_name }}' ) self.cache = get_cache('default') self.cache_key = SiteConfiguration.get_cache_key() self.cache.clear() SiteConfiguration.objects.all().delete()
def test_cache_prefix_overriding(self): key = SiteConfiguration.get_cache_key() prefix = key.partition(':')[0] self.assertEqual(prefix, 'other')