# Path: tests/functional/testcases.py
# class LiveServerTestCase(TestCaseMixin, BaseLiveServerTestCase):
# 
#     """Base test case for in-browser functional tests."""
# 
#     initial_url = None
#     login_button_value = 'Log in'
# 
#     def login(self):
#         self.browser.fill('username', self.username)
#         self.browser.fill('password', self.password)
#         self.browser.find_by_value(self.login_button_value).click()
# 
#     def create_staff_user(self, **kwargs):
#         kwargs.setdefault('is_staff', True)
#         kwargs.setdefault('is_superuser', True)
#         return super(LiveServerTestCase, self).create_user(**kwargs)
# 
#     def setUp(self):
#         self.browser = Browser('django')
#         if self.initial_url is not None:
#             self.browser.visit("{}{}".format(
#                 self.live_server_url,
#                 self.initial_url,
#             ))
# 
#     def tearDown(self):
#         self.browser.quit()


from .testcases import LiveServerTestCase


class AdminLoginTest(LiveServerTestCase):

    initial_url = "/admin/"

    def test_invalid_username(self):
        """Ensure error shown when logging in with an invalid username."""
        assert not self.browser.find_by_css('.errornote')
        self.login()
        assert "case-sensitive" in \
            self.browser.find_by_css('.alert-danger').text

    def test_incorrect_password(self):
        """Ensure error shown when logging in with an incorrect password."""
        assert not self.browser.find_by_css('.alert-danger')
        self.create_user(is_staff=True, password="other password")
        self.login()
        assert "case-sensitive" in \
            self.browser.find_by_css('.alert-danger').text

    def test_valid_credentials(self):
        """Ensure logging in with valid credentials redirects to admin."""
        assert "Log out" not in self.browser.find_by_css('body').text
        self.create_user(is_staff=True)
        self.login()
        assert "Log out" in self.browser.find_by_css('body').text



# Path: tests/functional/testcases.py
# class LiveServerTestCase(TestCaseMixin, BaseLiveServerTestCase):
# 
#     """Base test case for in-browser functional tests."""
# 
#     initial_url = None
#     login_button_value = 'Log in'
# 
#     def login(self):
#         self.browser.fill('username', self.username)
#         self.browser.fill('password', self.password)
#         self.browser.find_by_value(self.login_button_value).click()
# 
#     def create_staff_user(self, **kwargs):
#         kwargs.setdefault('is_staff', True)
#         kwargs.setdefault('is_superuser', True)
#         return super(LiveServerTestCase, self).create_user(**kwargs)
# 
#     def setUp(self):
#         self.browser = Browser('django')
#         if self.initial_url is not None:
#             self.browser.visit("{}{}".format(
#                 self.live_server_url,
#                 self.initial_url,
#             ))
# 
#     def tearDown(self):
#         self.browser.quit()


# Path: tests/functional/test_authentication.py
from .testcases import LiveServerTestCase



class AdminLoginTest(LiveServerTestCase):

    initial_url = "/admin/"

    def test_invalid_username(self):
        """Ensure error shown when logging in with an invalid username."""
        assert not self.browser.find_by_css('.errornote')
        self.login()
        assert "case-sensitive" in \
            self.browser.find_by_css('.alert-danger').text

    def test_incorrect_password(self):
        """Ensure error shown when logging in with an incorrect password."""
        assert not self.browser.find_by_css('.alert-danger')
        self.create_user(is_staff=True, password="other password")
        self.login()
        assert "case-sensitive" in \
            self.browser.find_by_css('.alert-danger').text

    def test_valid_credentials(self):
        """Ensure logging in with valid credentials redirects to admin."""
        assert "Log out" not in self.browser.find_by_css('body').text
        self.create_user(is_staff=True)
        self.login()
        assert "Log out" in self.browser.find_by_css('body').text



class LoginPageTest(LiveServerTestCase):