def test_delete_user_raises_when_group_creator(models): request, user = Mock(), Mock() models.Group.created_by.return_value.count.return_value = 10 with pytest.raises(admin.UserDeletionError): admin.delete_user(request, user)
def test_delete_user_disassociate_group_memberships(): request = Mock() user = Mock(groups=[Mock()]) admin.delete_user(request, user) assert user.groups == []
def test_delete_user_deletes_annotations(elasticsearch_helpers, api_storage): request, user = Mock(), MagicMock() annotation_1 = {'_id': 'annotation-1'} annotation_2 = {'_id': 'annotation-2'} elasticsearch_helpers.scan.return_value = [annotation_1, annotation_2] admin.delete_user(request, user) assert api_storage.delete_annotation.mock_calls == [ call(request, 'annotation-1'), call(request, 'annotation-2') ]
def test_delete_user_queries_annotations(elasticsearch_helpers): request = DummyRequest(es=Mock(), db=Mock()) user = MagicMock(username=u'bob') admin.delete_user(request, user) elasticsearch_helpers.scan.assert_called_once_with( client=request.es.conn, query={ 'query': { 'filtered': { 'filter': {'term': {'user': u'acct:[email protected]'}}, 'query': {'match_all': {}} } } } )
def test_delete_user_deletes_user(): request, user = Mock(), MagicMock() admin.delete_user(request, user) request.db.delete.assert_called_once_with(user)