added login test
This commit is contained in:
		
							parent
							
								
									b1ba9e2cd0
								
							
						
					
					
						commit
						6becd8278b
					
				| 
						 | 
					@ -5,33 +5,22 @@ from django.test import Client
 | 
				
			||||||
from django.contrib.auth.models import User
 | 
					from django.contrib.auth.models import User
 | 
				
			||||||
#from django.urls import reverse
 | 
					#from django.urls import reverse
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# class LoginTestCase(unittest.TestCase):
 | 
					class LoginTestCase(TestCase):
 | 
				
			||||||
#     def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
#         self.client = Client()
 | 
					        self.client = Client()
 | 
				
			||||||
#         self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe')
 | 
					        self.user = User.objects.create_user('vladimir', 'vladimir@reiherzehe.com', 'reiherzehe')
 | 
				
			||||||
#
 | 
					
 | 
				
			||||||
#     def testLogin(self):
 | 
					    def testLogin(self):
 | 
				
			||||||
#         self.client.login(username='vladimir', password='reiherzehe')
 | 
					        self.client.login(username='vladimir', password='reiherzehe')
 | 
				
			||||||
#         response = self.client.get('accounts/')
 | 
					        response = self.client.get('/')
 | 
				
			||||||
#         self.assertEqual(response.status_code, 200)
 | 
					        self.assertContains(response, 'Du bist eingeloggt als vladimir@reiherzehe.com', status_code=200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SimpleTest(TestCase):
 | 
					class SimpleTest(TestCase):
 | 
				
			||||||
    def setUp(self):
 | 
					    def setUp(self):
 | 
				
			||||||
        #User.objects.create_superuser('testuser', 'nomail@nomail.com', 'testpasswd')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Every test needs a client.
 | 
					 | 
				
			||||||
        self.client = Client()
 | 
					        self.client = Client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_details(self):
 | 
					    def test_details(self):
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Issue a GET request.
 | 
					 | 
				
			||||||
        response = self.client.get('/')
 | 
					        response = self.client.get('/')
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Check that the response is 200 OK.
 | 
					 | 
				
			||||||
        self.assertEqual(response.status_code, 302)
 | 
					        self.assertEqual(response.status_code, 302)
 | 
				
			||||||
        # print(response.url)
 | 
					 | 
				
			||||||
        #
 | 
					 | 
				
			||||||
        response2 = self.client.get(response.url)
 | 
					        response2 = self.client.get(response.url)
 | 
				
			||||||
        # # print(response2.content)
 | 
					 | 
				
			||||||
        #
 | 
					 | 
				
			||||||
        self.assertContains( response2, 'Bitte via Wolke einloggen:', status_code=200)
 | 
					        self.assertContains( response2, 'Bitte via Wolke einloggen:', status_code=200)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue