tests.py 762 Bytes
Newer Older
1
"""
2
Tests for mobile API utilities.
3 4 5
"""

import ddt
6
from django.test import TestCase
7

8
from .utils import mobile_course_access, mobile_view
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27


@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"))