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())
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())
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())