Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. import unittest
  2.  
  3. from base import BaseTestCase
  4.  
  5.  
  6. class Tests(BaseTestCase):
  7.  
  8.     # def test_index_page(self):
  9.     #     """TEST: render index page"""
  10.     #
  11.     #     response = self.client.get('/', content_type='html/text')
  12.     #     self.assertEqual(response.status_code, 200)
  13.  
  14.     def test_user_registration(self):
  15.         """TEST: user registration"""
  16.  
  17.         response = self.client.post('/account/registration/', data=dict(username="test", email="te@st.com", password="test"))
  18.         print(response.status_code, response.data)
  19.         self.assertEqual(response.status_code, 201)
  20.  
  21.     def test_registration_validation(self):
  22.         """TEST: registration validation"""
  23.  
  24.         response = self.client.post('/account/registration/', data=dict(username="test", email="te@", password="test"))
  25.         self.assertEqual(response.status_code, 404)
  26.  
  27.     def test_user_login(self):
  28.         """TEST: user login"""
  29.  
  30.         response = self.client.post('/account/login/', data=dict(username="admin", password="admin"))
  31.         self.assertEqual(response.status_code, 200)
  32.  
  33.     def test_login_undefined_user(self):
  34.         response = self.client.post('/account/login/', data=dict(username="test", password="test"))
  35.         self.assertEqual(response.status_code, 404)
  36.  
  37.     def test_login_wrong_password(self):
  38.         response = self.client.post('/account/login/', data=dict(username="admin", password="test"))
  39.         self.assertEqual(response.status_code, 404)
  40.  
  41. if __name__ == '__main__':
  42.     unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement