Files
edx-platform/lms/djangoapps/commerce/api/v1/tests/test_models.py
Feanil Patel 9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00

38 lines
1.1 KiB
Python

""" Tests for models. """
import ddt
from django.test import TestCase
from course_modes.models import CourseMode
from ..models import Course
@ddt.ddt
class CourseTests(TestCase):
""" Tests for Course model. """
def setUp(self):
super(CourseTests, self).setUp()
self.course = Course('a/b/c', [])
@ddt.unpack
@ddt.data(
('credit', 'Credit'),
('professional', 'Professional Education'),
('no-id-professional', 'Professional Education'),
('verified', 'Verified Certificate'),
('honor', 'Honor Certificate'),
('audit', 'Audit'),
)
def test_get_mode_display_name(self, slug, expected_display_name):
""" Verify the method properly maps mode slugs to display names. """
mode = CourseMode(mode_slug=slug)
self.assertEqual(self.course.get_mode_display_name(mode), expected_display_name)
def test_get_mode_display_name_unknown_slug(self):
""" Verify the method returns the slug if it has no known mapping. """
mode = CourseMode(mode_slug='Blah!')
self.assertEqual(self.course.get_mode_display_name(mode), mode.mode_slug)