
""" Test login view"""

from django.test import TestCase, Client
from administrator.models import User


class LogInTest(TestCase):

    """Test login view"""

    def setUp(self):
        self.client = Client()
        self.users_credentials = {
            "correct_user": {'email':'valid@email.com',
                             'password':'gfhjkm12',
                             'username':'CorrectUser',
                             'status' : User.ACTIVE
            },
            "banned_user": {'email':'banned@email.com',
                            'password':'gfhjkm12',
                            'username':'BannedUser',
                            'status': User.BANNED
            },
            "unregistered_user": {'email': 'unregistered@email.com',
                                  'password': 'gfhjkm12',
            }
        }
        User.objects.create_user(**self.users_credentials["correct_user"])
        User.objects.create_user(**self.users_credentials["banned_user"])

    def test_login_correct_user(self):
        """Tests whether user can login with correct data """
        response = self.client.post('/account/login/',
                                    self.users_credentials["correct_user"],
                                    follow=True
        )
        self.assertContains(response, "Logout")

    def test_login_banned_user(self):
        """Tests whether banned user can't login """
        context = ("To proceed, please login with an account "
                   "that has access.")
        response = self.client.post('/account/login/',
                                     self.users_credentials["banned_user"],
                                     follow=True
        )
        self.assertContains(response, context)

    def test_login_unregistered_user(self):
        """Tests whether user that isn't in database can't login"""
        context = "Please try again."
        response = self.client.post('/account/login/',
                                    self.users_credentials["unregistered_user"],
                                    follow=True
        )
        self.assertContains(response, context)




@@ -1,9 +1,7 @@
-%0A
 %22%22%22
- 
 Test
@@ -57,16 +57,17 @@
  Client%0A
+%0A
 from adm
@@ -144,24 +144,25 @@
 t login view
+.
 %22%22%22%0A%0A    def
@@ -1043,33 +1043,32 @@
 %0A        %22%22%22Test
-s
  whether user ca
@@ -1092,17 +1092,17 @@
 ect data
- 
+.
 %22%22%22%0A    
@@ -1380,33 +1380,32 @@
 %0A        %22%22%22Test
-s
  whether banned 
@@ -1420,17 +1420,17 @@
 't login
- 
+.
 %22%22%22%0A    
@@ -1824,17 +1824,16 @@
  %22%22%22Test
-s
  whether
@@ -1872,16 +1872,17 @@
 't login
+.
 %22%22%22%0A    
@@ -2101,32 +2101,32 @@
 =True%0A        )%0A
+
         self.ass
@@ -2157,10 +2157,8 @@
 ntext)%0A%0A
-%0A%0A

Fix docstrings