Skip to content

Commit

Permalink
Test docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanouil Konstantinidis committed Dec 18, 2015
1 parent be05b9d commit d455475
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rest_framework_docs/api_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
from django.contrib.admindocs.views import simplify_regex


Expand All @@ -24,7 +25,7 @@ def __get_allowed_methods__(self):
return [m.upper() for m in self.callback.cls.http_method_names if hasattr(self.callback.cls, m)]

def __get_docstring__(self):
return self.callback.cls.__doc__
return inspect.getdoc(self.callback)

def __get_serializer_fields__(self):
fields = []
Expand Down
1 change: 1 addition & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_index_view_with_endpoints(self):
self.assertEqual(response.context["endpoints"][0].name_parent, "accounts")
self.assertEqual(response.context["endpoints"][0].allowed_methods, ['POST', 'OPTIONS'])
self.assertEqual(response.context["endpoints"][0].path, "/accounts/login/")
self.assertEqual(response.context["endpoints"][0].docstring, "A view that allows users to login providing their username and password.")
self.assertEqual(len(response.context["endpoints"][0].fields), 2)
self.assertEqual(response.context["endpoints"][0].fields[0]["type"], "CharField")
self.assertTrue(response.context["endpoints"][0].fields[0]["required"])
Expand Down
6 changes: 6 additions & 0 deletions tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class TestView(TemplateView):


class LoginView(APIView):
"""
A view that allows users to login providing their username and password.
"""

throttle_classes = ()
permission_classes = ()
Expand All @@ -42,6 +45,9 @@ class UserRegistrationView(generics.CreateAPIView):


class UserProfileView(generics.RetrieveUpdateAPIView):
"""
An endpoint for users to view and update their profile information.
"""

serializer_class = serializers.UserProfileSerializer

Expand Down

0 comments on commit d455475

Please sign in to comment.