* Use full LMS imports paths in LMS settings and urls modules * Use full LMS import paths in Studio settings and urls modules * Import from lms.djangoapps.badges instead of badges * Import from lms.djangoapps.branding instead of branding * Import from lms.djangoapps.bulk_email instead of bulk_email * Import from lms.djangoapps.bulk_enroll instead of bulk_enroll * Import from lms.djangoapps.ccx instead of ccx * Import from lms.djangoapps.course_api instead of course_api * Import from lms.djangoapps.course_blocks instead of course_blocks * Import from lms.djangoapps.course_wiki instead of course_wiki * Import from lms.djangoapps.courseware instead of courseware * Import from lms.djangoapps.dashboard instead of dashboard * Import from lms.djangoapps.discussion import discussion * Import from lms.djangoapps.email_marketing instead of email_marketing * Import from lms.djangoapps.experiments instead of experiments * Import from lms.djangoapps.gating instead of gating * Import from lms.djangoapps.grades instead of grades * Import from lms.djangoapps.instructor_analytics instead of instructor_analytics * Import form lms.djangoapps.lms_xblock instead of lms_xblock * Import from lms.djangoapps.lti_provider instead of lti_provider * Import from lms.djangoapps.mobile_api instead of mobile_api * Import from lms.djangoapps.rss_proxy instead of rss_proxy * Import from lms.djangoapps.static_template_view instead of static_template_view * Import from lms.djangoapps.survey instead of survey * Import from lms.djangoapps.verify_student instead of verify_student * Stop suppressing EdxPlatformDeprecatedImportWarnings
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
"""
|
|
Tests for the Video Branding configuration.
|
|
"""
|
|
|
|
|
|
from django.core.exceptions import ValidationError
|
|
from django.test import TestCase
|
|
|
|
from lms.djangoapps.branding.models import BrandingInfoConfig
|
|
|
|
|
|
class BrandingInfoConfigTest(TestCase):
|
|
"""
|
|
Test the BrandingInfoConfig model.
|
|
"""
|
|
|
|
def setUp(self):
|
|
super(BrandingInfoConfigTest, self).setUp()
|
|
self.configuration_string = """{
|
|
"CN": {
|
|
"url": "http://www.xuetangx.com",
|
|
"logo_src": "http://www.xuetangx.com/static/images/logo.png",
|
|
"logo_tag": "Video hosted by XuetangX.com"
|
|
}
|
|
}"""
|
|
self.config = BrandingInfoConfig(configuration=self.configuration_string)
|
|
|
|
def test_create(self):
|
|
"""
|
|
Tests creation of configuration.
|
|
"""
|
|
self.config.save()
|
|
self.assertEqual(self.config.configuration, self.configuration_string)
|
|
|
|
def test_clean_bad_json(self):
|
|
"""
|
|
Tests if bad Json string was given.
|
|
"""
|
|
self.config = BrandingInfoConfig(configuration='{"bad":"test"')
|
|
self.assertRaises(ValidationError, self.config.clean)
|
|
|
|
def test_get(self):
|
|
"""
|
|
Tests get configuration from saved string.
|
|
"""
|
|
self.config.enabled = True
|
|
self.config.save()
|
|
expected_config = {
|
|
"CN": {
|
|
"url": "http://www.xuetangx.com",
|
|
"logo_src": "http://www.xuetangx.com/static/images/logo.png",
|
|
"logo_tag": "Video hosted by XuetangX.com"
|
|
}
|
|
}
|
|
self.assertEqual(self.config.get_config(), expected_config)
|
|
|
|
def test_get_not_enabled(self):
|
|
"""
|
|
Tests get configuration that is not enabled.
|
|
"""
|
|
self.config.enabled = False
|
|
self.config.save()
|
|
self.assertEqual(self.config.get_config(), {})
|