/
tests.py
59 lines (49 loc) · 1.91 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
Tests for mobile API utilities.
"""
import ddt
from django.test import TestCase
from mobile_api.models import MobileApiConfig
from .utils import mobile_course_access, mobile_view
@ddt.ddt
class TestMobileAPIDecorators(TestCase):
"""
Basic tests for mobile api decorators to ensure they retain the docstrings.
"""
@ddt.data(mobile_view, mobile_course_access)
def test_function_decorator(self, decorator):
@decorator()
def decorated_func():
"""
Test docstring of decorated function.
"""
pass
self.assertIn("Test docstring of decorated function.", decorated_func.__doc__)
self.assertEquals(decorated_func.__name__, "decorated_func")
self.assertTrue(decorated_func.__module__.endswith("tests"))
class TestMobileApiConfig(TestCase):
"""
Tests MobileAPIConfig
"""
def test_video_profile_list(self):
"""Check that video_profiles config is returned in order as a list"""
MobileApiConfig(video_profiles="mobile_low,mobile_high,youtube").save()
video_profile_list = MobileApiConfig.get_video_profiles()
self.assertEqual(
video_profile_list,
[u'mobile_low', u'mobile_high', u'youtube']
)
def test_video_profile_list_with_whitespace(self):
"""Check video_profiles config with leading and trailing whitespace"""
MobileApiConfig(video_profiles=" mobile_low , mobile_high,youtube ").save()
video_profile_list = MobileApiConfig.get_video_profiles()
self.assertEqual(
video_profile_list,
[u'mobile_low', u'mobile_high', u'youtube']
)
def test_empty_video_profile(self):
"""Test an empty video_profile"""
MobileApiConfig(video_profiles="").save()
video_profile_list = MobileApiConfig.get_video_profiles()
self.assertEqual(video_profile_list, [])