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

3
import mimetypes
Adam Palay committed
4
from mock import patch
5

6
from django.test import TestCase
Adam Palay committed
7
from django.core.urlresolvers import reverse
8 9 10

from edxmako import add_lookup, LOOKUP
from lms import startup
Adam Palay committed
11
from xmodule.modulestore.tests.factories import CourseFactory
12
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
13
from util import keyword_substitution
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 38 39 40 41 42 43
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
        self.assertEqual(len([dir for dir in directories if 'external_module' in dir]), 1)

        # This should not clear the directories list
        startup.enable_microsites()
        directories = LOOKUP['main'].directories
        self.assertEqual(len([dir for dir in directories if 'external_module' in dir]), 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 58 59 60
        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.
        """
        url = reverse('info', args=[self.course.id.to_deprecated_string()])
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)