Commit 4d197e10 by Chris Dodge

fix some violations. Build up karma

parent d32e7a5b
...@@ -226,7 +226,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -226,7 +226,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
module_store = modulestore('direct') module_store = modulestore('direct')
course = module_store.get_item(Location(['i4x', 'edX', 'full', 'course', '6.002_Spring_2012', None])) course = module_store.get_item(Location(['i4x', 'edX', 'full', 'course', '6.002_Spring_2012', None]))
self.assertGreater(len(course.textbooks), 0) self.assertGreater(len(course.textbooks), 0)
def test_static_tab_reordering(self): def test_static_tab_reordering(self):
import_from_xml(modulestore(), 'common/test/data/', ['full']) import_from_xml(modulestore(), 'common/test/data/', ['full'])
...@@ -301,7 +301,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -301,7 +301,6 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# make sure the parent no longer points to the child object which was deleted # make sure the parent no longer points to the child object which was deleted
self.assertFalse(sequential.location.url() in chapter.children) self.assertFalse(sequential.location.url() in chapter.children)
def test_about_overrides(self): def test_about_overrides(self):
''' '''
This test case verifies that a course can use specialized override for about data, e.g. /about/Fall_2012/effort.html This test case verifies that a course can use specialized override for about data, e.g. /about/Fall_2012/effort.html
......
...@@ -10,9 +10,9 @@ class CourseUpdateTest(CourseTestCase): ...@@ -10,9 +10,9 @@ class CourseUpdateTest(CourseTestCase):
'''Go through each interface and ensure it works.''' '''Go through each interface and ensure it works.'''
# first get the update to force the creation # first get the update to force the creation
url = reverse('course_info', url = reverse('course_info',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'name': self.course_location.name}) 'name': self.course_location.name})
self.client.get(url) self.client.get(url)
init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">' init_content = '<iframe width="560" height="315" src="http://www.youtube.com/embed/RocY-Jd93XU" frameborder="0">'
...@@ -20,9 +20,9 @@ class CourseUpdateTest(CourseTestCase): ...@@ -20,9 +20,9 @@ class CourseUpdateTest(CourseTestCase):
payload = {'content': content, payload = {'content': content,
'date': 'January 8, 2013'} 'date': 'January 8, 2013'}
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.post(url, json.dumps(payload), "application/json") resp = self.client.post(url, json.dumps(payload), "application/json")
...@@ -31,25 +31,25 @@ class CourseUpdateTest(CourseTestCase): ...@@ -31,25 +31,25 @@ class CourseUpdateTest(CourseTestCase):
self.assertHTMLEqual(payload['content'], content) self.assertHTMLEqual(payload['content'], content)
first_update_url = reverse('course_info_json', first_update_url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': payload['id']}) 'provided_id': payload['id']})
content += '<div>div <p>p<br/></p></div>' content += '<div>div <p>p<br/></p></div>'
payload['content'] = content payload['content'] = content
resp = self.client.post(first_update_url, json.dumps(payload), resp = self.client.post(first_update_url, json.dumps(payload),
"application/json") "application/json")
self.assertHTMLEqual(content, json.loads(resp.content)['content'], self.assertHTMLEqual(content, json.loads(resp.content)['content'],
"iframe w/ div") "iframe w/ div")
# now put in an evil update # now put in an evil update
content = '<ol/>' content = '<ol/>'
payload = {'content': content, payload = {'content': content,
'date': 'January 11, 2013'} 'date': 'January 11, 2013'}
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.post(url, json.dumps(payload), "application/json") resp = self.client.post(url, json.dumps(payload), "application/json")
...@@ -58,25 +58,24 @@ class CourseUpdateTest(CourseTestCase): ...@@ -58,25 +58,24 @@ class CourseUpdateTest(CourseTestCase):
self.assertHTMLEqual(content, payload['content'], "self closing ol") self.assertHTMLEqual(content, payload['content'], "self closing ol")
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.get(url) resp = self.client.get(url)
payload = json.loads(resp.content) payload = json.loads(resp.content)
self.assertTrue(len(payload) == 2) self.assertTrue(len(payload) == 2)
# can't test non-json paylod b/c expect_json throws error # can't test non-json paylod b/c expect_json throws error
# try json w/o required fields # try json w/o required fields
self.assertContains( self.assertContains(self.client.post(url, json.dumps({'garbage': 1}),
self.client.post(url, json.dumps({'garbage': 1}), "application/json"),
"application/json"), 'Failed to save', status_code=400)
'Failed to save', status_code=400)
# now try to update a non-existent update # now try to update a non-existent update
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': '9'}) 'provided_id': '9'})
content = 'blah blah' content = 'blah blah'
payload = {'content': content, payload = {'content': content,
'date': 'January 21, 2013'} 'date': 'January 21, 2013'}
...@@ -89,8 +88,8 @@ class CourseUpdateTest(CourseTestCase): ...@@ -89,8 +88,8 @@ class CourseUpdateTest(CourseTestCase):
payload = {'content': content, payload = {'content': content,
'date': 'January 11, 2013'} 'date': 'January 11, 2013'}
url = reverse('course_info_json', kwargs={'org': self.course_location.org, url = reverse('course_info_json', kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
self.assertContains( self.assertContains(
self.client.post(url, json.dumps(payload), "application/json"), self.client.post(url, json.dumps(payload), "application/json"),
...@@ -101,8 +100,8 @@ class CourseUpdateTest(CourseTestCase): ...@@ -101,8 +100,8 @@ class CourseUpdateTest(CourseTestCase):
payload = {'content': content, payload = {'content': content,
'date': 'January 11, 2013'} 'date': 'January 11, 2013'}
url = reverse('course_info_json', kwargs={'org': self.course_location.org, url = reverse('course_info_json', kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.post(url, json.dumps(payload), "application/json") resp = self.client.post(url, json.dumps(payload), "application/json")
payload = json.loads(resp.content) payload = json.loads(resp.content)
...@@ -110,8 +109,8 @@ class CourseUpdateTest(CourseTestCase): ...@@ -110,8 +109,8 @@ class CourseUpdateTest(CourseTestCase):
# now try to delete a non-existent update # now try to delete a non-existent update
url = reverse('course_info_json', kwargs={'org': self.course_location.org, url = reverse('course_info_json', kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': '19'}) 'provided_id': '19'})
payload = {'content': content, payload = {'content': content,
'date': 'January 21, 2013'} 'date': 'January 21, 2013'}
self.assertContains(self.client.delete(url), "delete", status_code=400) self.assertContains(self.client.delete(url), "delete", status_code=400)
...@@ -121,25 +120,25 @@ class CourseUpdateTest(CourseTestCase): ...@@ -121,25 +120,25 @@ class CourseUpdateTest(CourseTestCase):
payload = {'content': content, payload = {'content': content,
'date': 'January 28, 2013'} 'date': 'January 28, 2013'}
url = reverse('course_info_json', kwargs={'org': self.course_location.org, url = reverse('course_info_json', kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.post(url, json.dumps(payload), "application/json") resp = self.client.post(url, json.dumps(payload), "application/json")
payload = json.loads(resp.content) payload = json.loads(resp.content)
this_id = payload['id'] this_id = payload['id']
self.assertHTMLEqual(content, payload['content'], "single iframe") self.assertHTMLEqual(content, payload['content'], "single iframe")
# first count the entries # first count the entries
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': ''}) 'provided_id': ''})
resp = self.client.get(url) resp = self.client.get(url)
payload = json.loads(resp.content) payload = json.loads(resp.content)
before_delete = len(payload) before_delete = len(payload)
url = reverse('course_info_json', url = reverse('course_info_json',
kwargs={'org': self.course_location.org, kwargs={'org': self.course_location.org,
'course': self.course_location.course, 'course': self.course_location.course,
'provided_id': this_id}) 'provided_id': this_id})
resp = self.client.delete(url) resp = self.client.delete(url)
payload = json.loads(resp.content) payload = json.loads(resp.content)
self.assertTrue(len(payload) == before_delete - 1) self.assertTrue(len(payload) == before_delete - 1)
...@@ -6,6 +6,7 @@ from django.test.client import Client ...@@ -6,6 +6,7 @@ from django.test.client import Client
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
class InternationalizationTest(ModuleStoreTestCase): class InternationalizationTest(ModuleStoreTestCase):
""" """
Tests to validate Internationalization. Tests to validate Internationalization.
...@@ -38,34 +39,33 @@ class InternationalizationTest(ModuleStoreTestCase): ...@@ -38,34 +39,33 @@ class InternationalizationTest(ModuleStoreTestCase):
'org': 'MITx', 'org': 'MITx',
'number': '999', 'number': '999',
'display_name': 'Robot Super Course', 'display_name': 'Robot Super Course',
} }
def test_course_plain_english(self): def test_course_plain_english(self):
"""Test viewing the index page with no courses""" """Test viewing the index page with no courses"""
self.client = Client() self.client = Client()
self.client.login(username=self.uname, password=self.password) self.client.login(username=self.uname, password=self.password)
resp = self.client.get(reverse('index')) resp = self.client.get(reverse('index'))
self.assertContains(resp, self.assertContains(resp,
'<h1 class="title-1">My Courses</h1>', '<h1 class="title-1">My Courses</h1>',
status_code=200, status_code=200,
html=True) html=True)
def test_course_explicit_english(self): def test_course_explicit_english(self):
"""Test viewing the index page with no courses""" """Test viewing the index page with no courses"""
self.client = Client() self.client = Client()
self.client.login(username=self.uname, password=self.password) self.client.login(username=self.uname, password=self.password)
resp = self.client.get(reverse('index'), resp = self.client.get(reverse('index'),
{}, {},
HTTP_ACCEPT_LANGUAGE='en' HTTP_ACCEPT_LANGUAGE='en'
) )
self.assertContains(resp, self.assertContains(resp,
'<h1 class="title-1">My Courses</h1>', '<h1 class="title-1">My Courses</h1>',
status_code=200, status_code=200,
html=True) html=True)
# **** # ****
# NOTE: # NOTE:
...@@ -74,14 +74,13 @@ class InternationalizationTest(ModuleStoreTestCase): ...@@ -74,14 +74,13 @@ class InternationalizationTest(ModuleStoreTestCase):
# This test will break when we replace this fake 'test' language # This test will break when we replace this fake 'test' language
# with actual French. This test will need to be updated with # with actual French. This test will need to be updated with
# actual French at that time. # actual French at that time.
# Test temporarily disable since it depends on creation of dummy strings # Test temporarily disable since it depends on creation of dummy strings
@skip @skip
def test_course_with_accents (self): def test_course_with_accents(self):
"""Test viewing the index page with no courses""" """Test viewing the index page with no courses"""
self.client = Client() self.client = Client()
self.client.login(username=self.uname, password=self.password) self.client.login(username=self.uname, password=self.password)
resp = self.client.get(reverse('index'), resp = self.client.get(reverse('index'),
{}, {},
HTTP_ACCEPT_LANGUAGE='fr' HTTP_ACCEPT_LANGUAGE='fr'
...@@ -90,8 +89,8 @@ class InternationalizationTest(ModuleStoreTestCase): ...@@ -90,8 +89,8 @@ class InternationalizationTest(ModuleStoreTestCase):
TEST_STRING = u'<h1 class="title-1">' \ TEST_STRING = u'<h1 class="title-1">' \
+ u'My \xc7\xf6\xfcrs\xe9s L#' \ + u'My \xc7\xf6\xfcrs\xe9s L#' \
+ u'</h1>' + u'</h1>'
self.assertContains(resp, self.assertContains(resp,
TEST_STRING, TEST_STRING,
status_code=200, status_code=200,
html=True) html=True)
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