'Expiration test without superusers'

def test_login_expiration(self):

    old_settings = settings.ADMINS
    self.reset.append(conf.AUTH.BACKEND.set_for_testing(['desktop.auth.backend.AllowFirstUserDjangoBackend']))
    self.reset.append(conf.AUTH.EXPIRES_AFTER.set_for_testing(0))
    self.reset.append(conf.AUTH.EXPIRE_SUPERUSERS.set_for_testing(False))
    client = make_logged_in_client(username=self.test_username, password='test')
    client.get('/accounts/logout')
    user = User.objects.get(username=self.test_username)
    try:
        user.is_superuser = True
        user.save()
        response = client.post('/accounts/login/', dict(username=self.test_username, password='test'), follow=True)
        assert_equal(200, response.status_code, 'Expected    ok    status.')
        client.get('/accounts/logout')
        settings.ADMINS = [(self.test_username, 'test@test.com')]
        user.is_superuser = False
        user.save()
        response = client.post('/accounts/login/', dict(username=self.test_username, password='test'), follow=True)
        assert_equal(200, response.status_code, 'Expected    ok    status.')
        assert_true(('Account    deactivated.    Please    contact    an    <a    href="mailto:test@test.com">administrator</a>' in response.content), response.content)
        settings.ADMINS = []
        response = client.post('/accounts/login/', dict(username=self.test_username, password='test'), follow=True)
        assert_equal(200, response.status_code, 'Expected    ok    status.')
        assert_true(('Account    deactivated.    Please    contact    an    administrator.' in response.content), response.content)
    finally:
        settings.ADMINS = old_settings
