Ejemplo n.º 1
0
def test_bit_operation_with_expiration():
    # Given that temporary bitop keys are set to expire in 1 second
    bm_expire = Bitmapist(client, temp_ttl=1)
    bm_expire.delete_all()

    # When a temporary bit op is created (this one with the NOT bitop)
    bm_expire.mark_attribute('paid_user', 4)
    non_paid = bm_expire.bit_op_not(bm_expire.get_attribute('paid_user'))

    # It exists at first
    assert 5 in non_paid

    # But after 1 second, i.e. the TTL, has passed
    time.sleep(1)

    # Then the bitmap doesn't exist anymore
    assert len(non_paid) == 0
Ejemplo n.º 2
0
def test_bit_operation_with_expiration():
    # Given that temporary bitop keys are set to expire in 1 second
    bm_expire = Bitmapist(client, temp_ttl=1)
    bm_expire.delete_all()

    # When a temporary bit op is created (this one with the NOT bitop)
    bm_expire.mark_attribute('paid_user', 4)
    non_paid = bm_expire.bit_op_not(bm_expire.get_attribute('paid_user'))

    # It exists at first
    assert 5 in non_paid

    # But after 1 second, i.e. the TTL, has passed
    time.sleep(1)

    # Then the bitmap doesn't exist anymore
    assert len(non_paid) == 0