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

        user = self._user()

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

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

        self.assertIn('Please fix indicated errors.',
                      request.render_messages())
Ejemplo n.º 2
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.º 3
0
    def test_modify_user_error(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

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

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

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

        user = self._user()

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

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

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

        user = ptah.resolve(user.__uri__)
        self.assertIsNone(user)
Ejemplo n.º 5
0
    def test_modify_user_remove(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

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

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

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

        user = ptah.resolve(user.__uri__)
        self.assertIsNone(user)
Ejemplo n.º 6
0
    def test_modify_user(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()
        request = self.make_request(
            POST = {'form.buttons.modify': 'Modify',
                    'username': '******',
                    'email': '*****@*****.**',
                    'password': '******',
                    'validated': 'false',
                    'suspended': 'true'})

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

        self.assertEqual(user.username, 'NKim')
        self.assertEqual(user.email, '*****@*****.**')
Ejemplo n.º 7
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.º 8
0
    def test_modify_user(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()
        request = self.make_request(
            POST={
                'form.buttons.modify': 'Modify',
                'username': '******',
                'email': '*****@*****.**',
                'password': '******',
                'validated': 'false',
                'suspended': 'true'
            })

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

        self.assertEqual(user.username, 'NKim')
        self.assertEqual(user.email, '*****@*****.**')
Ejemplo n.º 9
0
    def test_modify_user_back(self):
        from ptahcrowd.user import ModifyUserForm

        user = self._user()

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

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

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

        user = self._user()

        request = self.make_request(
            POST = {'form.buttons.modify': 'Modify',
                    'username': '******',
                    'email': '*****@*****.**',
                    'password': '******',
                    'validated': 'false',
                    'suspended': 'true',
                    })

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

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

        user = self._user()

        request = self.make_request(
            POST={
                'form.buttons.modify': 'Modify',
                'username': '******',
                'email': '*****@*****.**',
                'password': '******',
                'validated': 'false',
                'suspended': 'true',
            })

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

        self.assertIsInstance(res, HTTPForbidden)
        self.assertEqual(str(res), 'Form authenticator is not found.')