Beispiel #1
0
    def test_sharingform_search_error(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(
            app, DummyRequest(POST={'form.buttons.search': 'Search'}))
        form.csrf = False
        form.update()

        self.assertIn('Please specify search term',
                      ptah.render_messages(form.request))
Beispiel #2
0
    def test_sharingform_search_error(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(app, DummyRequest(
                POST={'form.buttons.search': 'Search'}))
        form.csrf = False
        form.update()

        self.assertIn('Please specify search term',
                      ptah.render_messages(form.request))
Beispiel #3
0
    def test_sharingform_unset(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()
        app.__local_roles__ = {'test:user': [self.TestRole.id]}

        form = SharingForm(app, DummyRequest(
                session={'apps-sharing-term': 'email'},
                POST={'form.buttons.save': 'Save',
                      'userid-test:user': '******'}))
        form.csrf = False
        form.update()

        self.assertNotIn('test:user', app.__local_roles__)
Beispiel #4
0
    def test_sharingform_search(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(app, DummyRequest(
                POST={'form.buttons.search': 'Search',
                      'term': 'search term'}))
        form.csrf = False
        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertIn('apps-sharing-term', form.request.session)
        self.assertEqual(
            form.request.session['apps-sharing-term'], 'search term')
Beispiel #5
0
    def test_sharingform_update(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(app, DummyRequest(
                session={'apps-sharing-term': 'email'}))
        form.csrf = False
        form.update()

        self.assertEqual(len(form.users), 1)
        self.assertEqual(form.users[0].uri, 'test:user')
        self.assertIs(form.local_roles, app.__local_roles__)
        self.assertEqual(len(form.roles), 1)
        self.assertIs(form.roles[0], self.TestRole)
        self.assertEqual(form.get_principal('test:user').uri, 'test:user')
Beispiel #6
0
    def test_sharingform_unset(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()
        app.__local_roles__ = {'test:user': [self.TestRole.id]}

        form = SharingForm(
            app,
            DummyRequest(session={'apps-sharing-term': 'email'},
                         POST={
                             'form.buttons.save': 'Save',
                             'userid-test:user': '******'
                         }))
        form.csrf = False
        form.update()

        self.assertNotIn('test:user', app.__local_roles__)
Beispiel #7
0
    def test_sharingform_search(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(
            app,
            DummyRequest(POST={
                'form.buttons.search': 'Search',
                'term': 'search term'
            }))
        form.csrf = False
        res = form.update()

        self.assertIsInstance(res, HTTPFound)
        self.assertIn('apps-sharing-term', form.request.session)
        self.assertEqual(form.request.session['apps-sharing-term'],
                         'search term')
Beispiel #8
0
    def test_sharingform_update(self):
        from ptahcms.manage.apps import SharingForm

        app = self._make_app()

        form = SharingForm(
            app, DummyRequest(session={'apps-sharing-term': 'email'}))
        form.csrf = False
        form.update()

        self.assertEqual(len(form.users), 1)
        self.assertEqual(form.users[0].uri, 'test:user')
        self.assertIs(form.local_roles, app.__local_roles__)
        self.assertEqual(len(form.roles), 1)
        self.assertIs(form.roles[0], self.TestRole)
        self.assertEqual(form.get_principal('test:user').uri, 'test:user')