Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def test_delete_user_disassociate_group_memberships():
    request = Mock()
    user = Mock(groups=[Mock()])

    admin.delete_user(request, user)

    assert user.groups == []
Ejemplo n.º 3
0
def test_delete_user_disassociate_group_memberships():
    request = Mock()
    user = Mock(groups=[Mock()])

    admin.delete_user(request, user)

    assert user.groups == []
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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')
    ]
Ejemplo n.º 6
0
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')
    ]
Ejemplo n.º 7
0
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': {}}
                }
            }
        }
    )
Ejemplo n.º 8
0
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': {}}
                }
            }
        }
    )
Ejemplo n.º 9
0
def test_delete_user_deletes_user():
    request, user = Mock(), MagicMock()

    admin.delete_user(request, user)

    request.db.delete.assert_called_once_with(user)
Ejemplo n.º 10
0
def test_delete_user_deletes_user():
    request, user = Mock(), MagicMock()

    admin.delete_user(request, user)

    request.db.delete.assert_called_once_with(user)