Ejemplo n.º 1
0
    def test_regular_user_hide_private(self, super_mock, mocked_profile):
        mock_bundle = MagicMock()
        request_mock = MagicMock()
        r_attr = {'user': Profile(username='******')}
        attrs = {'request': request_mock}
        request_mock.configure_mock(**r_attr)
        mock_bundle.configure_mock(**attrs)

        groups = GroupAuthorization().read_list(['not_empty_but_fake'],
                                                mock_bundle)
        self.assertEqual(1, groups.count())
Ejemplo n.º 2
0
    def test_anonymous_user(self, super_mock, mocked_profile):
        mock_bundle = MagicMock()
        request_mock = MagicMock()
        r_attr = {'user': AnonymousUser()}
        attrs = {'request': request_mock}
        request_mock.configure_mock(**r_attr)
        mock_bundle.configure_mock(**attrs)

        groups = GroupAuthorization().read_list(['not_empty_but_fake'],
                                                mock_bundle)
        self.assertEqual(1, groups.count())
Ejemplo n.º 3
0
    def test_super_admin_user(self, super_mock):
        mock_bundle = MagicMock()
        request_mock = MagicMock()
        r_attr = {
            'user': Profile(username='******', is_staff=True, is_superuser=True)
        }
        attrs = {'request': request_mock}
        request_mock.configure_mock(**r_attr)
        mock_bundle.configure_mock(**attrs)

        groups = GroupAuthorization().read_list([], mock_bundle)
        self.assertEqual(
            Group.objects.exclude(name='anonymous').count(), groups.count())