Example #1
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 = GroupProfileAuthorization().read_list(['not_empty_but_fake'],
                                                       mock_bundle)
        self.assertEqual(1, groups.count())
Example #2
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 = GroupProfileAuthorization().read_list(['not_empty_but_fake'],
                                                       mock_bundle)
        self.assertEqual(1, groups.count())
Example #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 = GroupProfileAuthorization().read_list([], mock_bundle)
        self.assertEqual(GroupProfile.objects.all().count(), groups.count())
Example #4
0
 class Meta:
     queryset = GroupProfile.objects.all()
     resource_name = 'group_profile'
     allowed_methods = ['get']
     filtering = {
         'title': ALL,
         'slug': ALL,
         'categories': ALL_WITH_RELATIONS,
     }
     ordering = ['title', 'last_modified']
     authorization = GroupProfileAuthorization()