tests.py 2 KB
Newer Older
1 2
"""Tests for the lms module itself."""

3 4
import mimetypes

Adam Palay committed
5
from django.core.urlresolvers import reverse
6 7
from django.test import TestCase
from mock import patch
8

9
from edxmako import LOOKUP, add_lookup
10
from lms import startup
11
from openedx.features.course_experience import course_home_url_name
12
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
13
from xmodule.modulestore.tests.factories import CourseFactory
14

15 16 17 18 19 20 21 22 23 24 25 26 27

class LmsModuleTests(TestCase):
    """
    Tests for lms module itself.
    """

    def test_new_mimetypes(self):
        extensions = ['eot', 'otf', 'ttf', 'woff']
        for extension in extensions:
            mimetype, _ = mimetypes.guess_type('test.' + extension)
            self.assertIsNotNone(mimetype)


28 29 30 31 32 33 34 35 36 37
class TemplateLookupTests(TestCase):
    """
    Tests for TemplateLookup.
    """

    def test_add_lookup_to_main(self):
        """Test that any template directories added are not cleared when microsites are enabled."""

        add_lookup('main', 'external_module', __name__)
        directories = LOOKUP['main'].directories
38
        self.assertEqual(len([directory for directory in directories if 'external_module' in directory]), 1)
39 40 41 42

        # This should not clear the directories list
        startup.enable_microsites()
        directories = LOOKUP['main'].directories
43
        self.assertEqual(len([directory for directory in directories if 'external_module' in directory]), 1)
Adam Palay committed
44 45 46


@patch.dict('django.conf.settings.FEATURES', {'ENABLE_FEEDBACK_SUBMISSION': True})
47
class HelpModalTests(ModuleStoreTestCase):
Adam Palay committed
48 49
    """Tests for the help modal"""
    def setUp(self):
50
        super(HelpModalTests, self).setUp()
Adam Palay committed
51 52 53 54 55 56 57
        self.course = CourseFactory.create()

    def test_simple_test(self):
        """
        Simple test to make sure that you don't get a 500 error when the modal
        is enabled.
        """
58
        url = reverse(course_home_url_name(self.course.id), args=[self.course.id.to_deprecated_string()])
Adam Palay committed
59 60
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)