コード例 #1
0
def test_changefeed_delete(mock_cursor_next, mock_changefeed_data):
    from bigchaindb.backend import get_changefeed, connect
    from bigchaindb.backend.changefeed import ChangeFeed

    conn = connect()
    mock_cursor_next.side_effect = [mock.DEFAULT] + mock_changefeed_data

    outpipe = Pipe()
    changefeed = get_changefeed(conn, 'backlog', ChangeFeed.DELETE)
    changefeed.outqueue = outpipe
    changefeed.run_forever()

    assert outpipe.get()['msg'] == 'seems like we have a delete here'
    assert outpipe.qsize() == 0
コード例 #2
0
def test_changefeed_prefeed(mock_cursor_next, mock_changefeed_data):
    from bigchaindb.backend import get_changefeed, connect
    from bigchaindb.backend.changefeed import ChangeFeed

    conn = connect()
    mock_cursor_next.side_effect = [mock.DEFAULT] + mock_changefeed_data

    outpipe = Pipe()
    changefeed = get_changefeed(conn,
                                'backlog',
                                ChangeFeed.INSERT,
                                prefeed=[1, 2, 3])
    changefeed.outqueue = outpipe
    changefeed.run_forever()

    assert outpipe.qsize() == 4
コード例 #3
0
def test_changefeed_insert(mock_cursor_next, mock_changefeed_data):
    from bigchaindb.backend import get_changefeed, connect
    from bigchaindb.backend.changefeed import ChangeFeed

    # setup connection and mocks
    conn = connect()
    # mock the `next` method of the cursor to return the mocked data
    mock_cursor_next.side_effect = [mock.DEFAULT] + mock_changefeed_data

    outpipe = Pipe()
    changefeed = get_changefeed(conn, 'backlog', ChangeFeed.INSERT)
    changefeed.outqueue = outpipe
    changefeed.run_forever()

    assert outpipe.get()['msg'] == 'seems like we have an insert here'
    assert outpipe.qsize() == 0
コード例 #4
0
def test_changefeed_update(mock_cursor_next, mock_cursor_find_one,
                           mock_changefeed_data):
    from bigchaindb.backend import get_changefeed, connect
    from bigchaindb.backend.changefeed import ChangeFeed

    conn = connect()
    mock_cursor_next.side_effect = [mock.DEFAULT] + mock_changefeed_data
    mock_cursor_find_one.return_value = mock_changefeed_data[2]['o']

    outpipe = Pipe()
    changefeed = get_changefeed(conn, 'backlog', ChangeFeed.UPDATE)
    changefeed.outqueue = outpipe
    changefeed.run_forever()

    assert outpipe.get()['msg'] == 'seems like we have an update here'
    assert outpipe.qsize() == 0
    assert mock_cursor_find_one.called_once_with(
        {'_id': mock_changefeed_data[2]['o']}, {'_id': False})
コード例 #5
0
def test_changefeed_multiple_operations(mock_cursor_next, mock_cursor_find_one,
                                        mock_changefeed_data):
    from bigchaindb.backend import get_changefeed, connect
    from bigchaindb.backend.changefeed import ChangeFeed

    conn = connect()
    mock_cursor_next.side_effect = [mock.DEFAULT] + mock_changefeed_data
    mock_cursor_find_one.return_value = mock_changefeed_data[2]['o']

    outpipe = Pipe()
    changefeed = get_changefeed(conn, 'backlog',
                                ChangeFeed.INSERT | ChangeFeed.UPDATE)
    changefeed.outqueue = outpipe
    changefeed.run_forever()

    assert outpipe.get()['msg'] == 'seems like we have an insert here'
    assert outpipe.get()['msg'] == 'seems like we have an update here'
    assert outpipe.qsize() == 0
コード例 #6
0
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection, 'votes', ChangeFeed.INSERT)
コード例 #7
0
ファイル: election.py プロジェクト: sbellem/bigchaindb
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection, 'votes', ChangeFeed.INSERT)
コード例 #8
0
ファイル: vote.py プロジェクト: sbellem/bigchaindb
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection, 'bigchain', ChangeFeed.INSERT,
                                  prefeed=initial())
コード例 #9
0
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection, 'backlog',
                                  ChangeFeed.INSERT | ChangeFeed.UPDATE)
コード例 #10
0
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection,
                                  'bigchain',
                                  ChangeFeed.INSERT,
                                  prefeed=initial())
コード例 #11
0
ファイル: block.py プロジェクト: cgwyx/bigchaindb
def get_changefeed():
    connection = backend.connect(**bigchaindb.config['database'])
    return backend.get_changefeed(connection, 'backlog',
                                  ChangeFeed.INSERT | ChangeFeed.UPDATE)