test_favicon.py 1000 Bytes
Newer Older
James Tauber committed
1 2 3
from django.test import TestCase
from django.test.utils import override_settings

4
from nose.plugins.attrib import attr
James Tauber committed
5

6
from util.testing import UrlResetMixin
James Tauber committed
7 8


9
@attr(shard=1)
10 11 12 13
class FaviconTestCase(UrlResetMixin, TestCase):
    """
    Tests of the courseware favicon.
    """
James Tauber committed
14 15 16 17 18 19 20 21 22 23 24 25

    def test_favicon_redirect(self):
        resp = self.client.get("/favicon.ico")
        self.assertEqual(resp.status_code, 301)
        self.assertRedirects(
            resp,
            "/static/images/favicon.ico",
            status_code=301, target_status_code=404  # @@@ how to avoid 404?
        )

    @override_settings(FAVICON_PATH="images/foo.ico")
    def test_favicon_redirect_with_favicon_path_setting(self):
26
        self.reset_urls()
James Tauber committed
27 28 29 30 31 32 33 34

        resp = self.client.get("/favicon.ico")
        self.assertEqual(resp.status_code, 301)
        self.assertRedirects(
            resp,
            "/static/images/foo.ico",
            status_code=301, target_status_code=404  # @@@ how to avoid 404?
        )