MCPcopy
hub / github.com/django/django / test_clear_site_cache_domain

Method test_clear_site_cache_domain

tests/sites_tests/tests.py:178–194  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

176
177 @override_settings(SITE_ID=None, ALLOWED_HOSTS=["example2.com"])
178 def test_clear_site_cache_domain(self):
179 site = Site.objects.create(name="example2.com", domain="example2.com")
180 request = HttpRequest()
181 request.META = {
182 "SERVER_NAME": "example2.com",
183 "SERVER_PORT": "80",
184 }
185 get_current_site(request) # prime the models.SITE_CACHE
186 expected_cache = {site.domain: site}
187 self.assertEqual(models.SITE_CACHE, expected_cache)
188
189 # Site exists in 'default' database so using='other' shouldn't clear.
190 clear_site_cache(Site, instance=site, using="other")
191 self.assertEqual(models.SITE_CACHE, expected_cache)
192 # using='default' should clear.
193 clear_site_cache(Site, instance=site, using="default")
194 self.assertEqual(models.SITE_CACHE, {})
195
196 def test_unique_domain(self):
197 site = Site(domain=self.site.domain)

Callers

nothing calls this directly

Calls 4

HttpRequestClass · 0.90
get_current_siteFunction · 0.90
clear_site_cacheFunction · 0.90
createMethod · 0.45

Tested by

no test coverage detected