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/applicants/tests/test_browser.py

    r13365 r13394  
    609609        self.assertTrue(
    610610            'You logged in.' in self.browser.contents)
     611
     612    def test_maintenance_mode(self):
     613        config = grok.getSite()['configuration']
     614        self.login()
     615        # Applicant  logged in.
     616        self.assertTrue('You logged in' in self.browser.contents)
     617        self.assertTrue("Joan None" in self.browser.contents)
     618        # If maintenance mode is enabled, applicant is immediately logged out.
     619        config.maintmode_enabled_by = u'any_user'
     620        self.assertRaises(
     621            Unauthorized, self.browser.open, 'http://localhost/app/faculties')
     622        self.browser.open('http://localhost/app/login')
     623        self.assertTrue('The portal is in maintenance mode' in self.browser.contents)
     624        # Applicant really can't login if maintenance mode is enabled.
     625        self.login()
     626        # A second warning is raised.
     627        self.assertTrue(
     628            'The portal is in maintenance mode. You can\'t login!'
     629            in self.browser.contents)
     630        return
    611631
    612632    def test_applicant_access(self):
     
    12501270
    12511271    def test_register_applicant_create(self):
     1272        config = grok.getSite()['configuration']
     1273        config.maintmode_enabled_by = u'any_user'
    12521274        self.assertEqual(len(self.app['applicants'][container_name_1]), 1)
    12531275        # An applicant can register himself.
    12541276        self.browser.open(self.container_path)
    12551277        self.browser.getLink("Register for application").click()
    1256         # Fill the edit form with suitable values
     1278        self.assertTrue(
     1279            'The portal is in maintenance mode' in self.browser.contents)
     1280        config.maintmode_enabled_by = None
     1281        self.browser.getLink("Register for application").click()
     1282        # The edit form now opens and can be filled with suitable values
    12571283        self.browser.getControl(name="form.firstname").value = 'Anna'
    12581284        self.browser.getControl(name="form.lastname").value = 'Kurios'
Note: See TracChangeset for help on using the changeset viewer.