Commit ddcd166b by Victor Shnayder

make tests pass without LMS settings

parent 9e436644
from django.conf import settings from django.conf import settings
from django.test import TestCase from django.test import TestCase
from tempfile import NamedTemporaryFile from mock import Mock
import os import os
from override_settings import override_settings from override_settings import override_settings
from tempfile import NamedTemporaryFile
from status import get_site_status_msg from status import get_site_status_msg
import xmodule.modulestore.django # Get a name where we can put test files
from xmodule.modulestore.django import modulestore TMP_FILE = NamedTemporaryFile(delete=False)
from xmodule.modulestore import Location TMP_NAME = TMP_FILE.name
from xmodule.modulestore.xml_importer import import_from_xml # Close it--we just want the path.
TMP_FILE.close()
@override_settings(STATUS_MESSAGE_PATH=TMP_NAME)
class TestStatus(TestCase): class TestStatus(TestCase):
"""Test that the get_site_status_msg function does the right thing""" """Test that the get_site_status_msg function does the right thing"""
...@@ -49,15 +52,14 @@ class TestStatus(TestCase): ...@@ -49,15 +52,14 @@ class TestStatus(TestCase):
] ]
def setUp(self): def setUp(self):
xmodule.modulestore.django._MODULESTORES = {} """
courses = modulestore().get_courses() Mock courses, since we don't have to have full django
settings (common tests run without the lms settings imported)
def find_course(course_id): """
"""Assumes the course is present""" self.full = Mock()
return [c for c in courses if c.id==course_id][0] self.full.id = 'edX/full/2012_Fall'
self.toy = Mock()
self.full = find_course("edX/full/6.002_Spring_2012") self.toy.id = 'edX/toy/2012_Fall'
self.toy = find_course("edX/toy/2012_Fall")
def create_status_file(self, contents): def create_status_file(self, contents):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment