def test_overriding_skips_custom_overrides_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/foo.gif" self.request.GET = {"_escaped_fragment_": None} self.assertEqual( self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.txt" self.assertEqual(self.middleware.process_request(self.request), None)
def test_overriding_skips_custom_overrides_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/foo.gif" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.txt" self.assertEqual(self.middleware.process_request(self.request), None)
def test_overriding_skips_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None)
def test_has_escaped_fragment_skips_if_service_is_down(self): self.middleware = HashBangMiddleware() self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None)
def test_has_escaped_fragment_skips_if_disabled_via_enabled(self): self.middleware = HashBangMiddleware() self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None)
def setUp(self): super(HashBangMiddlewareTest, self).setUp() self.middleware = HashBangMiddleware() self.request = Mock() self.request.path = "/" self.request.GET = {}
class HashBangMiddlewareTest(TestCase): @override_settings(BACKEND='django_seo_js.backends.TestBackend') def setUp(self): super(HashBangMiddlewareTest, self).setUp() self.middleware = HashBangMiddleware() self.request = Mock() self.request.path = "/" self.request.GET = {} def test_has_escaped_fragment(self): self.request.GET = {"_escaped_fragment_": None} self.assertEqual( self.middleware.process_request(self.request).content, "Test") def test_does_not_have_escaped_fragment(self): self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(BACKEND='django_seo_js.backends.TestBackend', ENABLED=False) def test_has_escaped_fragment_skips_if_disabled_via_enabled(self): self.middleware = HashBangMiddleware() self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(BACKEND='django_seo_js.backends.TestServiceDownBackend') def test_has_escaped_fragment_skips_if_service_is_down(self): self.middleware = HashBangMiddleware() self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(BACKEND='django_seo_js.backends.TestBackend') def test_overriding_skips_sitemap_xml_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings( BACKEND='django_seo_js.backends.TestBackend', IGNORE_URLS=[ "/foo.html", "/bar/ibbity.html", ], IGNORE_EXTENSIONS=[], ) def test_overriding_skips_custom_overrides_xml_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual( self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.html" self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(BACKEND='django_seo_js.backends.TestBackend') def test_overriding_skips_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(BACKEND='django_seo_js.backends.TestBackend', IGNORE_EXTENSIONS=[ ".html", ".txt", ]) def test_overriding_skips_custom_overrides_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/foo.gif" self.request.GET = {"_escaped_fragment_": None} self.assertEqual( self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.txt" self.assertEqual(self.middleware.process_request(self.request), None)
class HashBangMiddlewareTest(TestCase): @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestBackend') def setUp(self): super(HashBangMiddlewareTest, self).setUp() self.middleware = HashBangMiddleware() self.request = Mock() self.request.path = "/" self.request.GET = {} def test_has_escaped_fragment(self): self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request).content, "Test") def test_does_not_have_escaped_fragment(self): self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestBackend', DEBUG=True) def test_has_escaped_fragment_skips_if_disabled_via_debug(self): self.middleware = HashBangMiddleware() self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestBackend', SEO_JS_ENABLED=False) def test_has_escaped_fragment_skips_if_disabled_via_enabled(self): self.middleware = HashBangMiddleware() self.request.GET = {} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestServiceDownBackend') def test_has_escaped_fragment_skips_if_service_is_down(self): self.middleware = HashBangMiddleware() self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestBackend') def test_overriding_skips_sitemap_xml_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings( SEO_JS_BACKEND='django_seo_js.backends.TestBackend', SEO_JS_IGNORE_URLS=["/foo.html", "/bar/ibbity.html", ], SEO_JS_IGNORE_EXTENSIONS=[], ) def test_overriding_skips_custom_overrides_xml_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.html" self.assertEqual(self.middleware.process_request(self.request), None) @override_settings(SEO_JS_BACKEND='django_seo_js.backends.TestBackend') def test_overriding_skips_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/sitemap.xml" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request), None) @override_settings( SEO_JS_BACKEND='django_seo_js.backends.TestBackend', SEO_JS_IGNORE_EXTENSIONS=[".html", ".txt", ] ) def test_overriding_skips_custom_overrides_gifs_by_default(self): self.middleware = HashBangMiddleware() self.request.path = "/foo.gif" self.request.GET = {"_escaped_fragment_": None} self.assertEqual(self.middleware.process_request(self.request).content, "Test") self.request.path = "/foo.html" self.assertEqual(self.middleware.process_request(self.request), None) self.request.path = "/bar/ibbity.txt" self.assertEqual(self.middleware.process_request(self.request), None)
def test_update_the_render_cache(self): from django_seo_js.helpers import update_cache_for_url self.middleware = HashBangMiddleware() self.assertEqual(update_cache_for_url("http://example.com"), True)
def test_update_skips_if_disabled_via_enabled(self): from django_seo_js.helpers import update_cache_for_url self.middleware = HashBangMiddleware() self.assertEqual(update_cache_for_url("http://example.com"), False)