Views test

This commit is contained in:
Pengwius 2021-01-10 01:14:34 +01:00
parent 06c983439e
commit b6ce36d9d4
2 changed files with 47 additions and 2 deletions

View file

@ -1,7 +1,7 @@
from django.test import SimpleTestCase
from django.urls import reverse, resolve
from app.views import default_view, content_view
from app.views import login
from app.views import login, grades, timetable, exams, homeworks, attendance, notes
class TestUrls(SimpleTestCase):
#views
@ -16,4 +16,28 @@ class TestUrls(SimpleTestCase):
#API
def test_login_is_resolved(self):
url = reverse('login')
self.assertEquals(resolve(url).func, login)
self.assertEquals(resolve(url).func, login)
def test_grades_is_resolved(self):
url = reverse('grades')
self.assertEquals(resolve(url).func, grades)
def test_timetable_is_resolved(self):
url = reverse('timetable')
self.assertEquals(resolve(url).func, timetable)
def test_exams_is_resolved(self):
url = reverse('exams')
self.assertEquals(resolve(url).func, exams)
def test_homeworks_is_resolved(self):
url = reverse('homeworks')
self.assertEquals(resolve(url).func, homeworks)
def test_attendance_is_resolved(self):
url = reverse('attendance')
self.assertEquals(resolve(url).func, attendance)
def test_notes_is_resolved(self):
url = reverse('notes')
self.assertEquals(resolve(url).func, notes)

21
tests/test_views.py Normal file
View file

@ -0,0 +1,21 @@
from django.test import TestCase, Client
from django.urls import reverse
import json
class TestViews(TestCase):
def setUp(self):
self.client = Client()
self.list_url = reverse('home')
self.detail_url = reverse('content')
def test_views(self):
#DEFAULT_VIEW
response = self.client.get(self.list_url)
self.assertEquals(response.status_code, 200)
self.assertTemplateUsed(response, 'index.html')
#CONTENT_VIEW
response = self.client.get(self.detail_url)
self.assertEquals(response.status_code, 302)