Ejemplo n.º 1
0
    def test_modify_user_error(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.modify': 'Modify'})

        view = ModifyUserForm(user, request)
        view.csrf = False
        view.update()

        self.assertIn(
            'Please fix indicated errors.',
            ptah.render_messages(request))
Ejemplo n.º 2
0
    def test_modify_user(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()
        f = ModifyUserForm(None, None)

        request = DummyRequest(
            POST = {'form.buttons.modify': 'Modify',
                    'name': 'NKim',
                    'login': '******',
                    'password': '******',
                    'validated': 'false',
                    'suspended': 'true'})

        view = ModifyUserForm(user, request)
        view.csrf = False
        view.update()

        self.assertEqual(user.name, 'NKim')
        self.assertEqual(user.login, '*****@*****.**')
Ejemplo n.º 3
0
    def test_modify_user_back(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.back': 'Back'})

        view = ModifyUserForm(user, request)
        res = view.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '..')
Ejemplo n.º 4
0
    def test_modify_user_forbidden(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.modify': 'Modify',
                    'name': 'NKim',
                    'login': '******',
                    'password': '******',
                    'validated': 'false',
                    'suspended': 'true',
                    })

        view = ModifyUserForm(user, request)
        res = None
        try:
            view.update()
        except Exception as err:
            res = err

        self.assertIsInstance(res, HTTPForbidden)
        self.assertEqual(str(res), 'Form authenticator is not found.')
Ejemplo n.º 5
0
    def test_modify_user_remove(self):
        from ptahcrowd.user import ModifyUserForm
        from ptahcrowd.provider import CrowdUser

        user = self._user()

        request = DummyRequest(
            POST = {'form.buttons.remove': 'Remove'})

        view = ModifyUserForm(user, request)
        view.csrf = False
        res = view.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '..')

        user = ptah.resolve(user.__uri__)
        self.assertIsNone(user)