Exemple #1
0
def test_cleanDeletedEditedItems():
    rs.set(EDITED + "NotExisted", "fjslfs")
    rs.set(EDITED + "NTR", "BTR")
    rs.set(EDITED + "百合", "百合")

    update.cleanDeletedItemsByPrefix(EDITED)

    assert rs.get(EDITED + "NTR")
    assert rs.get(EDITED + "百合")
    assert not rs.get(EDITED + "NotExisted")
Exemple #2
0
def test_cleanDeletedEditedItems():
    rs.set(EDITED+"NotExisted", "fjslfs")
    rs.set(EDITED+"NTR", "BTR")
    rs.set(EDITED+"百合", "百合")

    update.cleanDeletedItemsByPrefix(EDITED)

    assert rs.get(EDITED+"NTR")
    assert rs.get(EDITED+"百合")
    assert not rs.get(EDITED+"NotExisted")
Exemple #3
0
def test_cleanDeletedNewItems():
    rs.set(NEWITEM+"NotExisted", "fjslfs")
    rs.set(NEWITEM+"NTR", "BTR")
    rs.set(NEWITEM+"百合", "百合")

    update.cleanDeletedItemsByPrefix(NEWITEM)

    assert rs.get(NEWITEM+"NTR")
    assert rs.get(NEWITEM+"百合")
    assert not rs.get(NEWITEM+"NotExisted")

    _deletePrefix(NEWITEM)
Exemple #4
0
def test_cleanDeletedNewItems():
    rs.set(NEWITEM + "NotExisted", "fjslfs")
    rs.set(NEWITEM + "NTR", "BTR")
    rs.set(NEWITEM + "百合", "百合")

    update.cleanDeletedItemsByPrefix(NEWITEM)

    assert rs.get(NEWITEM + "NTR")
    assert rs.get(NEWITEM + "百合")
    assert not rs.get(NEWITEM + "NotExisted")

    _deletePrefix(NEWITEM)
Exemple #5
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")
Exemple #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")
Exemple #7
0
def authSina(code):
    client = weibo.APIClient(SinaAppKey, SinaAppSecret,
                             MoePadSite+"/sinacallback")
    r = client.request_access_token(code)
    client.set_access_token(r.access_token, r.expires_in)
    ruid = client.account.get_uid.get()
    #can get user type when callback from sina
    #so save the type in memcache, as long as
    #only on account get oauthed at a time, this works
    current_user_type = rs.get("current_user_type")
    print current_user_type
    if current_user_type == "original":
        WeiboAuthObj = OriWeiboAuth
    elif current_user_type == "retweet":
        WeiboAuthObj = RtWeiboAuth
    else:
        log.error("invalid callback user type autSina")
        raise Exception
    WeiboAuthObj.set(
        access_token=r.access_token,
        expires_in=r.expires_in,
        user_type=current_user_type, uid=ruid.uid)
    WeiboAuthObj.save()
    return r.access_token, r.expires_in
Exemple #8
0
def authSina(code):
    client = weibo.APIClient(SinaAppKey, SinaAppSecret,
                             MoePadSite + "/sinacallback")
    r = client.request_access_token(code)
    client.set_access_token(r.access_token, r.expires_in)
    ruid = client.account.get_uid.get()
    #can get user type when callback from sina
    #so save the type in memcache, as long as
    #only on account get oauthed at a time, this works
    current_user_type = rs.get("current_user_type")
    print current_user_type
    if current_user_type == "original":
        WeiboAuthObj = OriWeiboAuth
    elif current_user_type == "retweet":
        WeiboAuthObj = RtWeiboAuth
    else:
        log.error("invalid callback user type autSina")
        raise Exception
    WeiboAuthObj.set(access_token=r.access_token,
                     expires_in=r.expires_in,
                     user_type=current_user_type,
                     uid=ruid.uid)
    WeiboAuthObj.save()
    return r.access_token, r.expires_in