Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
irfanpule committed Jul 7, 2020
1 parent dbb1176 commit 8b7d171
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/accounts/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.test import TestCase
from django.test import Client

from academy.apps.accounts.models import User, Inbox
from academy.apps.offices.models import Setting, AuthSetting


class AccountsUserViewTest(TestCase):
fixtures = ['accounts.json', 'students.json']

def setUp(self):
Setting.objects.create()
AuthSetting.objects.create()

def test_inbox(self):
user = User.objects.get(email='[email protected]')
user.set_password('password123')
user.save()

login = self.client.login(username=user.username, password='password123')
self.assertTrue(login)

# normal url
url = '/accounts/inbox/'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

# with parameter page
url = '/accounts/inbox/?page=1'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

# wrong value parameter
url = '/accounts/inbox/?page=1%27'
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

0 comments on commit 8b7d171

Please sign in to comment.