from tests.Base import BaseTest

class TestLoginPageAccessCritera(BaseTest):

    def setUp(self):
        super().setUp()
        self.url = self.generate_url('login')

    def test_accessable_while_not_authenticated(self):
        tester = self.anonymous_user()
        resp = tester.get(self.url)
        self.assertEqual(200, resp.status_code)

    def test_redirected_while_authenticated_as_admin(self):
        tester = self.login_as_user_id(self.admin_user.id)
        resp = tester.get(self.url)
        self.assertEqual(302, resp.status_code)

    def test_redrected_while_authenticated_as_std_user(self):
        tester = self.login_as_user_id(self.std_user.id)
        resp = tester.get(self.url)
        self.assertEqual(302, resp.status_code)


