Exemplo n.º 1
0
def test_composite_filter():

    l1 = HistoryItem.new('a', {'log': 'history', 'resource': 'a'})
    l2 = HistoryItem.new('b', {'log': 'history', 'resource': 'b'})

    l1.save()
    l2.save()
    assert HistoryItem.composite.filter({'log': 'history',
                                         'resource': 'a'}) == [l1.key]
    assert HistoryItem.composite.filter({'log': 'history',
                                         'resource': 'b'}) == [l2.key]
Exemplo n.º 2
0
def test_composite_filter():

    l1 = HistoryItem.new('a', {'log': 'history', 'resource': 'a'})
    l2 = HistoryItem.new('b', {'log': 'history', 'resource': 'b'})

    l1.save()
    l2.save()
    assert HistoryItem.composite.filter({
        'log': 'history',
        'resource': 'a'
    }) == [l1.key]
    assert HistoryItem.composite.filter({
        'log': 'history',
        'resource': 'b'
    }) == [l2.key]
Exemplo n.º 3
0
def test_reversed_order_is_preserved():
    added = []
    for i in range(4):
        li = HistoryItem.new(str(i), {})
        li.save()
        added.append(li.key)
    added.reverse()
    assert list(HistoryItem.history.filter(StrInt.n_max(),
                                           StrInt.n_min(),
                                           max_results=2)) == added[:2]
Exemplo n.º 4
0
def test_reversed_order_is_preserved():
    added = []
    for i in range(4):
        li = HistoryItem.new(str(i), {})
        li.save()
        added.append(li.key)
    added.reverse()
    assert list(
        HistoryItem.history.filter(StrInt.n_max(),
                                   StrInt.n_min(),
                                   max_results=2)) == added[:2]
Exemplo n.º 5
0
def revert_uids(uids):
    """Reverts uids

    :param uids: iterable not generator
    """
    items = HistoryItem.multi_get(uids)

    for item in items:
        if is_update(item):
            _revert_update(item)
        elif item.action == CHANGES.remove.name:
            _revert_remove(item)
        elif is_create(item):
            _revert_run(item)
        else:
            log.debug('Action %s for resource %s is a side'
                      ' effect of another action', item.action, item.res)
Exemplo n.º 6
0
def revert_uids(uids):
    """Reverts uids

    :param uids: iterable not generator
    """
    items = HistoryItem.multi_get(uids)

    for item in items:
        if is_update(item):
            _revert_update(item)
        elif item.action == CHANGES.remove.name:
            _revert_remove(item)
        elif is_create(item):
            _revert_run(item)
        else:
            log.debug(
                'Action %s for resource %s is a side'
                ' effect of another action', item.action, item.res)
Exemplo n.º 7
0
def CL():
    rst = HistoryItem.bucket.get_index('$bucket',
                                       startkey='_',
                                       max_results=100000).results
    return HistoryItem.multi_get(rst)
Exemplo n.º 8
0
def CL():
    rst = HistoryItem.bucket.get_index('$bucket',
                                       startkey='_',
                                       max_results=100000).results
    return HistoryItem.multi_get(rst)