Skip to content

Commit

Permalink
Adds Test for UserList and get API.
Browse files Browse the repository at this point in the history
Adds pylint for api.
Removes all not-needed files.
  • Loading branch information
anselmos committed Apr 25, 2017
1 parent bfb2a44 commit f0baea1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pylint_all: requirements pylint

pylint:
pylint --load-plugins pylint_django bikingendorphines/web --rcfile=.pylintrc
pylint --load-plugins pylint_django bikingendorphines/api --rcfile=.pylintrc
pylint --load-plugins pylint_django bikingendorphines/bikingendorphines --rcfile=.pylintrc

unittest_all: prepare_db unittest
Expand Down
3 changes: 0 additions & 3 deletions bikingendorphines/api/admin.py

This file was deleted.

4 changes: 4 additions & 0 deletions bikingendorphines/api/apps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""
Apps configuration for API app.
"""
from __future__ import unicode_literals

from django.apps import AppConfig


class ApiConfig(AppConfig):
"Api Config"
name = 'api'
5 changes: 0 additions & 5 deletions bikingendorphines/api/models.py

This file was deleted.

16 changes: 15 additions & 1 deletion bikingendorphines/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from api.serializers import UserSerializer
from api.views import UserList
from web.models import User

from rest_framework.test import APIRequestFactory
from rest_framework.test import force_authenticate


class TestUserSerializer(unittest.TestCase):
Expand All @@ -26,3 +27,16 @@ def test_user_serialize_to_json(self):
{'height': 175, 'surname': u'Somlesna', 'id': None, 'weight': 80, 'name': u'Anselmos'}
)


class TestUserList(unittest.TestCase):
"UserList tests"

def test_user_get_return_json(self):
"test if using get returns json data"

view = UserList.as_view()
factory = APIRequestFactory()
request = factory.get("/api/user/")
force_authenticate(request)
response = view(request)
self.assertEquals(response.status_code, 200)
3 changes: 3 additions & 0 deletions bikingendorphines/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class UserList(APIView):
List all User's, or create a new snippet
"""

#pylint: disable=redefined-builtin
#pylint: disable=unused-argument
#pylint: disable=no-self-use
def get(self, request, format=None):
"GET"
users = User.objects.all()
Expand Down

0 comments on commit f0baea1

Please sign in to comment.