Пример #1
0
def test_bulk_update_annotations_scans_with_query(helpers):
    client = mock.Mock(spec_set=['conn', 'index'])

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=mock.sentinel.action)

    helpers.scan.assert_called_once_with(client=client.conn,
                                         index=client.index,
                                         query=mock.sentinel.query)
Пример #2
0
def test_bulk_update_annotations_scans_with_query(helpers):
    client = mock.Mock(spec_set=['conn', 'index'])

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=mock.sentinel.action)

    helpers.scan.assert_called_once_with(client=client.conn,
                                         index=client.index,
                                         query=mock.sentinel.query)
Пример #3
0
def test_bulk_update_annotations_generates_actions_for_each_annotation(helpers):
    action = mock.Mock(spec_set=[])
    client = mock.Mock(spec_set=['conn', 'index'])
    helpers.scan.return_value = [mock.sentinel.anno1,
                                 mock.sentinel.anno2,
                                 mock.sentinel.anno3]

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=action)

    assert action.call_args_list == [
        mock.call(client.index, mock.sentinel.anno1),
        mock.call(client.index, mock.sentinel.anno2),
        mock.call(client.index, mock.sentinel.anno3),
    ]
Пример #4
0
def test_bulk_update_annotations_generates_actions_for_each_annotation(helpers):
    action = mock.Mock(spec_set=[])
    client = mock.Mock(spec_set=['conn', 'index'])
    helpers.scan.return_value = [mock.sentinel.anno1,
                                 mock.sentinel.anno2,
                                 mock.sentinel.anno3]

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=action)

    assert action.call_args_list == [
        mock.call(client.index, mock.sentinel.anno1),
        mock.call(client.index, mock.sentinel.anno2),
        mock.call(client.index, mock.sentinel.anno3),
    ]
Пример #5
0
def test_bulk_update_annotations_calls_bulk_with_actions(helpers):
    action = mock.Mock(spec_set=[], side_effect=[
        mock.sentinel.action1,
        mock.sentinel.action2,
        mock.sentinel.action3,
    ])
    client = mock.Mock(spec_set=['conn', 'index'])
    helpers.scan.return_value = [mock.sentinel.anno1,
                                 mock.sentinel.anno2,
                                 mock.sentinel.anno3]

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=action)

    helpers.bulk.assert_called_once_with(client=client.conn,
                                         actions=[mock.sentinel.action1,
                                                  mock.sentinel.action2,
                                                  mock.sentinel.action3])
Пример #6
0
def test_bulk_update_annotations_calls_bulk_with_actions(helpers):
    action = mock.Mock(spec_set=[], side_effect=[
        mock.sentinel.action1,
        mock.sentinel.action2,
        mock.sentinel.action3,
    ])
    client = mock.Mock(spec_set=['conn', 'index'])
    helpers.scan.return_value = [mock.sentinel.anno1,
                                 mock.sentinel.anno2,
                                 mock.sentinel.anno3]

    worker.bulk_update_annotations(client=client,
                                   query=mock.sentinel.query,
                                   action=action)

    helpers.bulk.assert_called_once_with(client=client.conn,
                                         actions=[mock.sentinel.action1,
                                                  mock.sentinel.action2,
                                                  mock.sentinel.action3])