from app.test_base import BaseTestCase

class TestTopLevelFunctions(BaseTestCase):
    def test_index_response(self):
        response = self.client.get('/')
        self.assert200(response)

from app.test_base import BaseTestCase

class TestTopLevelFunctions(BaseTestCase):
    def test_index_response(self):
        response = self.client.get('/')
        self.assert200(response)

    def test_login_required(self):
        self.check_login_required('/scores/add', '/login?next=%2Fscores%2Fadd')
        self.check_login_required('/judging/presentation/new', '/login?next=%2Fjudging%2Fpresentation%2Fnew')
        self.check_login_required('/judging/technical/new', '/login?next=%2Fjudging%2Ftechnical%2Fnew')
        self.check_login_required('/judging/core_values/new', '/login?next=%2Fjudging%2Fcore_values%2Fnew')
        self.check_login_required('/settings', '/login?next=%2Fsettings')
        self.check_login_required('/review', '/login?next=%2Freview')
        self.check_login_required('/teams/new', '/login?next=%2Fteams%2Fnew')
        self.check_login_required('/scores/playoffs', '/login?next=%2Fscores%2Fplayoffs')

    def check_login_required(self, attempted_location, redirected_location):
        response = self.client.get(attempted_location)
        self.assertTrue(response.status_code in (301, 302))
        self.assertEqual(response.location, 'http://' + self.app.config['SERVER_NAME'] + redirected_location)

Add test to verify login required for protected pages
Add test to verify login required for protected pages

  from app.test_base import BaseTestCase
  
  class TestTopLevelFunctions(BaseTestCase):
      def test_index_response(self):
          response = self.client.get('/')
          self.assert200(response)
  
+     def test_login_required(self):
+         self.check_login_required('/scores/add', '/login?next=%2Fscores%2Fadd')
+         self.check_login_required('/judging/presentation/new', '/login?next=%2Fjudging%2Fpresentation%2Fnew')
+         self.check_login_required('/judging/technical/new', '/login?next=%2Fjudging%2Ftechnical%2Fnew')
+         self.check_login_required('/judging/core_values/new', '/login?next=%2Fjudging%2Fcore_values%2Fnew')
+         self.check_login_required('/settings', '/login?next=%2Fsettings')
+         self.check_login_required('/review', '/login?next=%2Freview')
+         self.check_login_required('/teams/new', '/login?next=%2Fteams%2Fnew')
+         self.check_login_required('/scores/playoffs', '/login?next=%2Fscores%2Fplayoffs')
+ 
+     def check_login_required(self, attempted_location, redirected_location):
+         response = self.client.get(attempted_location)
+         self.assertTrue(response.status_code in (301, 302))
+         self.assertEqual(response.location, 'http://' + self.app.config['SERVER_NAME'] + redirected_location)
+ 
Add test to verify login required for protected pages
## Code Before:
from app.test_base import BaseTestCase

class TestTopLevelFunctions(BaseTestCase):
    def test_index_response(self):
        response = self.client.get('/')
        self.assert200(response)

## Instruction:
Add test to verify login required for protected pages
## Code After:
from app.test_base import BaseTestCase

class TestTopLevelFunctions(BaseTestCase):
    def test_index_response(self):
        response = self.client.get('/')
        self.assert200(response)

    def test_login_required(self):
        self.check_login_required('/scores/add', '/login?next=%2Fscores%2Fadd')
        self.check_login_required('/judging/presentation/new', '/login?next=%2Fjudging%2Fpresentation%2Fnew')
        self.check_login_required('/judging/technical/new', '/login?next=%2Fjudging%2Ftechnical%2Fnew')
        self.check_login_required('/judging/core_values/new', '/login?next=%2Fjudging%2Fcore_values%2Fnew')
        self.check_login_required('/settings', '/login?next=%2Fsettings')
        self.check_login_required('/review', '/login?next=%2Freview')
        self.check_login_required('/teams/new', '/login?next=%2Fteams%2Fnew')
        self.check_login_required('/scores/playoffs', '/login?next=%2Fscores%2Fplayoffs')

    def check_login_required(self, attempted_location, redirected_location):
        response = self.client.get(attempted_location)
        self.assertTrue(response.status_code in (301, 302))
        self.assertEqual(response.location, 'http://' + self.app.config['SERVER_NAME'] + redirected_location)
