from django.test import TestCase # import unittest from django.test import Client from django.contrib.auth.models import User #from django.urls import reverse 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('/') 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) class NoLoginTestCase(TestCase): 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)