Skip to content

Commit

Permalink
Merge 59a73da into afc3e87
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanj-k committed Jan 22, 2019
2 parents afc3e87 + 59a73da commit 06c0a09
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 10,
}

# Jwt configuration
Expand Down
17 changes: 17 additions & 0 deletions authors/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,24 @@ def setUp(self):
self.reset_password_invalid_email = {
"email": "kenyamoja@gmail.com"
}
def get_token(self):
"""Register and login a user"""

# register user
self.client.post(
self.user_url,
self.user_data,
format='json'
)
self.client.get(self.get_verify_url(self.user_data))
response = self.client.post(
self.login_url,
self.login_data,
format="json"
)
token = response.data['token']
return token

def get_verify_url(self, user):

self.register_user()
Expand Down
22 changes: 22 additions & 0 deletions authors/tests/test_pagination.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# python and django imports
import json
from rest_framework.views import status
from django.urls import reverse

# local imports
from .base_test import TestBase


class TestPagination(TestBase):
"""This class has tests for pagination setting."""

def test_profiles_pagination(self):
token = self.get_token()
url = reverse('profiles:all_profiles')
self.client.credentials(HTTP_AUTHORIZATION='Bearer ' + token)
response = self.client.get(url)
self.assertIn('count', response.data)
self.assertIn('next', response.data)
self.assertIn('previous', response.data)
self.assertIn('results', response.data)

0 comments on commit 06c0a09

Please sign in to comment.