Commit 4fde73fa by Jonathan Piacenti

Address notes.

parent cb4ed420
......@@ -12,8 +12,10 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from badges.models import CourseCompleteImageConfiguration, validate_badge_image, BadgeClass, BadgeAssertion, \
from badges.models import (
CourseCompleteImageConfiguration, validate_badge_image, BadgeClass, BadgeAssertion,
CourseBadgesDisabledError
)
from badges.tests.factories import BadgeClassFactory, BadgeAssertionFactory, RandomBadgeClassFactory
from certificates.tests.test_models import TEST_DATA_ROOT
from student.tests.factories import UserFactory
......@@ -112,12 +114,12 @@ class BadgeClassTest(ModuleStoreTestCase):
exception.
"""
course_key = CourseFactory.create(metadata={'issue_badges': False}).location.course_key
self.assertRaises(
CourseBadgesDisabledError, BadgeClass.get_badge_class,
slug='test_slug', issuing_component='test_component', description='Attempted override',
criteria='test', display_name='Testola', image_file_handle=get_image('good'),
course_id=course_key,
)
with self.assertRaises(CourseBadgesDisabledError):
BadgeClass.get_badge_class(
slug='test_slug', issuing_component='test_component', description='Attempted override',
criteria='test', display_name='Testola', image_file_handle=get_image('good'),
course_id=course_key,
)
def test_get_badge_class_create(self):
"""
......
......@@ -193,6 +193,7 @@ class TestUserServiceAPI(TestCase):
self.runtime.service(self.mock_block, 'user_tags').get_tag('fake_scope', self.key)
@ddt
class TestBadgingService(ModuleStoreTestCase):
"""Test the badging service interface"""
......@@ -232,17 +233,12 @@ class TestBadgingService(ModuleStoreTestCase):
runtime = self.create_runtime()
self.assertFalse(runtime.service(self.mock_block, 'badging'))
@data(True, False)
@patch.dict(settings.FEATURES, {'ENABLE_OPENBADGES': True})
def test_course_badges_disabled(self):
self.course_id = CourseFactory.create(metadata={'issue_badges': False}).location.course_key
runtime = self.create_runtime()
self.assertFalse(runtime.service(self.mock_block, 'badging').course_badges_enabled)
@patch.dict(settings.FEATURES, {'ENABLE_OPENBADGES': True})
def test_course_badges_enabled(self):
self.course_id = CourseFactory.create(metadata={'issue_badges': True}).location.course_key
def test_course_badges_toggle(self, toggle):
self.course_id = CourseFactory.create(metadata={'issue_badges': toggle}).location.course_key
runtime = self.create_runtime()
self.assertTrue(runtime.service(self.mock_block, 'badging').course_badges_enabled)
self.assertIs(runtime.service(self.mock_block, 'badging').course_badges_enabled, toggle)
@patch.dict(settings.FEATURES, {'ENABLE_OPENBADGES': True})
def test_get_badge_class(self):
......
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