mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Updated tests for view name and description
Updated the tests to use the default view_name and view_description functions in the formatter through the default in settings.
This commit is contained in:
parent
11d7c1838a
commit
5a374955b1
|
@ -6,7 +6,6 @@ from rest_framework.compat import apply_markdown, smart_text
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.tests.description import ViewWithNonASCIICharactersInDocstring
|
from rest_framework.tests.description import ViewWithNonASCIICharactersInDocstring
|
||||||
from rest_framework.tests.description import UTF8_TEST_DOCSTRING
|
from rest_framework.tests.description import UTF8_TEST_DOCSTRING
|
||||||
from rest_framework.utils.formatting import get_view_name, get_view_description
|
|
||||||
|
|
||||||
# We check that docstrings get nicely un-indented.
|
# We check that docstrings get nicely un-indented.
|
||||||
DESCRIPTION = """an example docstring
|
DESCRIPTION = """an example docstring
|
||||||
|
@ -58,7 +57,7 @@ class TestViewNamesAndDescriptions(TestCase):
|
||||||
"""
|
"""
|
||||||
class MockView(APIView):
|
class MockView(APIView):
|
||||||
pass
|
pass
|
||||||
self.assertEqual(get_view_name(MockView), 'Mock')
|
self.assertEqual(MockView().get_view_name(), 'Mock')
|
||||||
|
|
||||||
def test_view_description_uses_docstring(self):
|
def test_view_description_uses_docstring(self):
|
||||||
"""Ensure view descriptions are based on the docstring."""
|
"""Ensure view descriptions are based on the docstring."""
|
||||||
|
@ -78,7 +77,7 @@ class TestViewNamesAndDescriptions(TestCase):
|
||||||
|
|
||||||
# hash style header #"""
|
# hash style header #"""
|
||||||
|
|
||||||
self.assertEqual(get_view_description(MockView), DESCRIPTION)
|
self.assertEqual(MockView().get_view_description(), DESCRIPTION)
|
||||||
|
|
||||||
def test_view_description_supports_unicode(self):
|
def test_view_description_supports_unicode(self):
|
||||||
"""
|
"""
|
||||||
|
@ -86,7 +85,7 @@ class TestViewNamesAndDescriptions(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
get_view_description(ViewWithNonASCIICharactersInDocstring),
|
ViewWithNonASCIICharactersInDocstring().get_view_description(),
|
||||||
smart_text(UTF8_TEST_DOCSTRING)
|
smart_text(UTF8_TEST_DOCSTRING)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ class TestViewNamesAndDescriptions(TestCase):
|
||||||
"""
|
"""
|
||||||
class MockView(APIView):
|
class MockView(APIView):
|
||||||
pass
|
pass
|
||||||
self.assertEqual(get_view_description(MockView), '')
|
self.assertEqual(MockView().get_view_description(), '')
|
||||||
|
|
||||||
def test_markdown(self):
|
def test_markdown(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user