eva/evapp/tests.py

42 lines
1.5 KiB
Python
Raw Normal View History

2020-12-23 10:42:57 +00:00
from django.test import TestCase
2021-09-13 13:32:16 +00:00
from django.test import Client
from django.contrib.auth.models import User
2021-09-14 09:58:22 +00:00
from .forms import ITForm
2021-09-13 13:32:16 +00:00
2021-09-14 05:17:36 +00:00
class LoginTestCase(TestCase):
def setUp(self):
self.client = Client()
self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe')
self.client.login(username='vladimir', password='reiherzehe')
self.response = self.client.get('/')
2021-09-14 05:17:36 +00:00
def testLogin(self):
self.assertContains(self.response, 'Du bist eingeloggt als vladimir@reiherzehe.com', status_code=200)
def testDebugWarning(self):
with self.settings(DEBUG=True):
self.assertContains(self.response, "WARNUNG! Test-MODUS aktiviert. Es werden keine Mails verschickt!", status_code=200)
2021-09-13 13:32:16 +00:00
2021-09-14 07:58:41 +00:00
class NoLoginTestCase(TestCase):
2021-09-13 13:32:16 +00:00
def setUp(self):
self.client = Client()
def test_details(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 302)
response2 = self.client.get(response.url)
self.assertContains( response2, 'Bitte via Wolke einloggen:', status_code=200)
2021-09-14 09:58:22 +00:00
class ITFORMTestCase(TestCase):
def test_mac(self):
form = ITForm(data={"vendor": 'MAC', 'os': 'UBU'})
#print (form.errors)
self.assertEqual(form.non_field_errors(), ['Ein MAC sollte Mac OS installiert haben'])
def test_ubu(self):
form = ITForm(data={"vendor": 'STANDARD', 'os': 'UBU'})
#print (form.errors)
self.assertNotEqual(form.non_field_errors(), ['Ein MAC sollte Mac OS installiert haben'])