Ignore:
Timestamp:
6 Nov 2015, 05:43:37 (9 years ago)
Author:
Henrik Bettermann
Message:

Implement portal maintenance mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13349 r13394  
    13871387        filewidget.add_file(filecontents, 'text/plain', 'students.csv')
    13881388        self.browser.getControl(name='SUBMIT').click()
     1389        self.browser.getLink("Switch maintenance mode").click()
    13891390        self.browser.getLink('Process data').click()
    13901391        button = lookup_submit_value(
     
    14131414        filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv')
    14141415        self.browser.getControl(name='SUBMIT').click()
     1416        # Meanwhile maintenance mode is disabled again.
     1417        self.browser.getLink("Switch maintenance mode").click()
    14151418        self.browser.getLink('Process data').click()
    14161419        button = lookup_submit_value(
     
    23762379            '...You logged in...', self.browser.contents)
    23772380
     2381    def test_maintenance_mode(self):
     2382        config = grok.getSite()['configuration']
     2383        self.browser.open(self.login_path)
     2384        self.browser.getControl(name="form.login").value = self.student_id
     2385        self.browser.getControl(name="form.password").value = 'spwd'
     2386        self.browser.getControl("Login").click()
     2387        # Student logged in.
     2388        self.assertTrue('You logged in' in self.browser.contents)
     2389        self.assertTrue("Anna Tester" in self.browser.contents)
     2390        # If maintenance mode is enabled, student is immediately logged out.
     2391        config.maintmode_enabled_by = u'any_user'
     2392        self.assertRaises(
     2393            Unauthorized, self.browser.open, 'http://localhost/app/faculties')
     2394        self.browser.open('http://localhost/app/login')
     2395        self.assertTrue('The portal is in maintenance mode' in self.browser.contents)
     2396        # Student really can't login if maintenance mode is enabled.
     2397        self.browser.open(self.login_path)
     2398        self.browser.getControl(name="form.login").value = self.student_id
     2399        self.browser.getControl(name="form.password").value = 'spwd'
     2400        self.browser.getControl("Login").click()
     2401        # A second warning is raised.
     2402        self.assertTrue(
     2403            'The portal is in maintenance mode. You can\'t login!'
     2404            in self.browser.contents)
     2405        return
     2406
    23782407    def test_student_clearance(self):
    23792408        # Student cant login if their password is not set
Note: See TracChangeset for help on using the changeset viewer.