Commit 7e1ca6e3 by Victor Shnayder

Pass course_id instead of course to get_site_status_msg

* makes testing easier -- don't need course objects
parent 3feb24f9
......@@ -10,7 +10,7 @@ import sys
log = logging.getLogger(__name__)
def get_site_status_msg(course):
def get_site_status_msg(course_id):
"""
Look for a file settings.STATUS_MESSAGE_PATH. If found, read it,
parse as json, and do the following:
......@@ -33,9 +33,9 @@ def get_site_status_msg(course):
status_dict = json.loads(content)
msg = status_dict.get('global', None)
if course and course.id in status_dict:
if course_id in status_dict:
msg = msg + "<br>" if msg else ''
msg += status_dict[course.id]
msg += status_dict[course_id]
return msg
except:
......
from django.conf import settings
from django.test import TestCase
from mock import Mock
import os
from override_settings import override_settings
from tempfile import NamedTemporaryFile
......@@ -53,13 +52,11 @@ class TestStatus(TestCase):
def setUp(self):
"""
Mock courses, since we don't have to have full django
Fake course ids, since we don't have to have full django
settings (common tests run without the lms settings imported)
"""
self.full = Mock()
self.full.id = 'edX/full/2012_Fall'
self.toy = Mock()
self.toy.id = 'edX/toy/2012_Fall'
self.full_id = 'edX/full/2012_Fall'
self.toy_id = 'edX/toy/2012_Fall'
def create_status_file(self, contents):
"""
......@@ -88,6 +85,6 @@ class TestStatus(TestCase):
print "course=None:"
self.assertEqual(get_site_status_msg(None), exp_none)
print "course=toy:"
self.assertEqual(get_site_status_msg(self.toy), exp_toy)
self.assertEqual(get_site_status_msg(self.toy_id), exp_toy)
print "course=full:"
self.assertEqual(get_site_status_msg(self.full), exp_full)
self.assertEqual(get_site_status_msg(self.full_id), exp_full)
......@@ -15,11 +15,11 @@ from status.status import get_site_status_msg
<%block cached="False">
<%
try:
c = course
course_id = course.id
except:
# can't figure out a better way to get at a possibly-defined course var
c = None
site_status_msg = get_site_status_msg(c)
course_id = None
site_status_msg = get_site_status_msg(course_id)
%>
% if site_status_msg:
<div class="site-status">
......
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