Beispiel #1
0
def test_verifyingKeyExpired():
    expired_time = time.time()
    future_time = expired_time + 120
    assert not update.verifyingKeyExpired("shouldnotexisted")

    rs.zadd(VERIFYING_SET, "expired", expired_time)
    rs.zadd(VERIFYING_SET, "future_item", future_time)

    assert update.verifyingKeyExpired("expired")
    assert not update.verifyingKeyExpired("future_item")

    rs.zrem(VERIFYING_SET, "expired")
    rs.zrem(VERIFYING_SET, "future_item")
Beispiel #2
0
def test_verifyingKeyExpired():
    expired_time = time.time()
    future_time = expired_time + 120
    assert not update.verifyingKeyExpired("shouldnotexisted")

    rs.zadd(VERIFYING_SET, "expired", expired_time)
    rs.zadd(VERIFYING_SET, "future_item", future_time)

    assert update.verifyingKeyExpired("expired")
    assert not update.verifyingKeyExpired("future_item")

    rs.zrem(VERIFYING_SET, "expired")
    rs.zrem(VERIFYING_SET, "future_item")
Beispiel #3
0
def test_filterExistedItems():
    _deletePrefix(NEWITEM)
    _deletePrefix(EDITED)
    rs.delete(VERIFYING_SET)

    rs.set(NEWITEM + "newitem", "newitem")
    rs.set(EDITED + "edited", "edited")
    rs.zadd(VERIFYING_SET, "verifying", 1)

    assert not update.filterExistedItems("newitem")
    assert not update.filterExistedItems("edited")
    assert not update.filterExistedItems("verifying")
    assert update.filterExistedItems("shouldnotexisted")

    rs.delete(NEWITEM + "newitem")
    rs.delete(EDITED + "edited")
    rs.zrem(VERIFYING_SET, "verifying")
Beispiel #4
0
def test_autoVerifyExpiredItems():
    curtime = time.time()
    expired_time = curtime
    future_time = curtime + 120

    rs.zadd(VERIFYING_SET, "expired", curtime)
    rs.zadd(VERIFYING_SET, "future_item", future_time)

    assert rs.zscore(VERIFYING_SET, "expired") == curtime

    update.autoVerifyExpiredItems()

    assert not rs.zscore(VERIFYING_SET, "expired")
    assert rs.zscore(VERIFYING_SET, "future_item") == future_time
    assert rs.get(NEWITEM+"expired") == "expired"

    rs.zrem(VERIFYING_SET, "future_item")
    rs.delete(NEWITEM+"expired")
Beispiel #5
0
def test_filterExistedItems():
    _deletePrefix(NEWITEM)
    _deletePrefix(EDITED)
    rs.delete(VERIFYING_SET)


    rs.set(NEWITEM+"newitem", "newitem")
    rs.set(EDITED+"edited", "edited")
    rs.zadd(VERIFYING_SET, "verifying", 1)

    assert not update.filterExistedItems("newitem")
    assert not update.filterExistedItems("edited")
    assert not update.filterExistedItems("verifying")
    assert update.filterExistedItems("shouldnotexisted")

    rs.delete(NEWITEM+"newitem")
    rs.delete(EDITED+"edited")
    rs.zrem(VERIFYING_SET, "verifying")
Beispiel #6
0
def test_autoVerifyExpiredItems():
    curtime = time.time()
    expired_time = curtime
    future_time = curtime + 120

    rs.zadd(VERIFYING_SET, "expired", curtime)
    rs.zadd(VERIFYING_SET, "future_item", future_time)

    assert rs.zscore(VERIFYING_SET, "expired") == curtime

    update.autoVerifyExpiredItems()

    assert not rs.zscore(VERIFYING_SET, "expired")
    assert rs.zscore(VERIFYING_SET, "future_item") == future_time
    assert rs.get(NEWITEM + "expired") == "expired"

    rs.zrem(VERIFYING_SET, "future_item")
    rs.delete(NEWITEM + "expired")