Exemple #1
0
    def test_create_user(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

        f = CreateUserForm(None, None)

        request = DummyRequest(
            POST = {'name': 'NKim',
                    'login': '******',
                    'password': '******',
                    'validated': 'false',
                    'suspended': 'true',
                    'form.buttons.create': 'Create'})
        request.POST[CreateUserForm.csrfname] = \
            request.session.get_csrf_token()

        mod = CrowdModule(None, request)

        view = CreateUserForm(mod, request)
        res = view.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')
        self.assertIn('User has been created.', ptah.render_messages(request))
        transaction.commit()

        user = ptah.auth_service.get_principal_bylogin('*****@*****.**')
        self.assertEqual(user.name, 'NKim')
        self.assertEqual(user.login, '*****@*****.**')
        self.assertTrue(user.suspended)
        self.assertFalse(user.validated)
Exemple #2
0
    def test_create_user_back(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

        request = DummyRequest(
            POST = {'form.buttons.back': 'Back'})
        mod = CrowdModule(None, request)

        view = CreateUserForm(mod, request)
        res = view.update()
        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')
Exemple #3
0
    def test_create_user_error(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

        request = self.make_request(POST={'form.buttons.create': 'Create'})
        request.POST[CreateUserForm.csrf_name] = \
            request.session.get_csrf_token()
        mod = CrowdModule(None, request)

        view = CreateUserForm(mod, request)
        view.update_form()
        self.assertIn('Please fix indicated errors.',
                      request.render_messages())
Exemple #4
0
    def test_create_user_error(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

        request = self.make_request(
            POST = {'form.buttons.create': 'Create'})
        request.POST[CreateUserForm.csrf_name] = \
            request.session.get_csrf_token()
        mod = CrowdModule(None, request)

        view = CreateUserForm(mod, request)
        view.update_form()
        self.assertIn(
            'Please fix indicated errors.',
            request.render_messages())
Exemple #5
0
    def test_create_user(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

        request = self.make_request(
            POST={
                'username': '******',
                'email': '*****@*****.**',
                'password': '******',
                'validated': 'false',
                'suspended': 'true',
                'form.buttons.create': 'Create'
            })
        request.POST[CreateUserForm.csrf_name] = \
            request.session.get_csrf_token()

        mod = CrowdModule(None, request)

        view = CreateUserForm(mod, request)
        res = view()

        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')
        self.assertIn('User has been created.', request.render_messages())
        transaction.commit()

        user = ptah.auth_service.get_principal_bylogin('*****@*****.**')
        self.assertEqual(user.username, 'NKim')
        self.assertEqual(user.email, '*****@*****.**')
        self.assertTrue(user.suspended)
        self.assertFalse(user.validated)
Exemple #6
0
    def test_create_user_back(self):
        from ptahcrowd.module import CrowdModule
        from ptahcrowd.user import CreateUserForm

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

        view = CreateUserForm(mod, request)
        res = view()
        self.assertIsInstance(res, HTTPFound)
        self.assertEqual(res.headers['location'], '.')