# Path: moedjpack/moepad/mputils.py
# def sub_dict(somedict, somekeys, default=None):
# def loggerInit(logfile):
# def utcnow():
# def _deletePrefix(key):
# def create_default_db():


import time
import moedjpack.moepad.update as update
from moedjpack.moepad.mputils import rs, logger, _deletePrefix
from moedjpack.moepad.mpdefs import *
    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")


def test_getItemTobeSend():
    # 0. test no item exist in either side
    _deletePrefix(EDITED)
    _deletePrefix(NEWITEM)
    result = update.getItemTobeSend()
    assert not (result[1])

    # 1. test when new items not exist, edited item exist
    rs.set(EDITED+"百合", "百合")
    rs.set(EDITED+"佐天泪子", "佐天泪子")
    assert update.getItemTobeSend()[1] in [EDITED+"百合", EDITED+"佐天泪子"]

    # 2. test when new items exist but is deleted
    rs.set(NEWITEM+"newitem1", "newitem1")
    rs.set(NEWITEM+"newitem2", "newitem2")
    assert update.getItemTobeSend()[1] in [EDITED+"佐天泪子", EDITED+"百合"]

    # 3. test when new items existed and existed in mb web pages
    rs.set(NEWITEM+"NTR", "NTR")
    rs.set(NEWITEM+"百合", "百合")

# Path: moedjpack/moepad/mputils.py
# def sub_dict(somedict, somekeys, default=None):
# def loggerInit(logfile):
# def utcnow():
# def _deletePrefix(key):
# def create_default_db():


# Path: moedjpack/moepad/tests/test_update.py
import time
import moedjpack.moepad.update as update
from moedjpack.moepad.mputils import rs, logger, _deletePrefix
from moedjpack.moepad.mpdefs import *

    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")


def test_getItemTobeSend():
    # 0. test no item exist in either side
    _deletePrefix(EDITED)
    _deletePrefix(NEWITEM)
    result = update.getItemTobeSend()
    assert not (result[1])

    # 1. test when new items not exist, edited item exist
    rs.set(EDITED+"百合", "百合")
    rs.set(EDITED+"佐天泪子", "佐天泪子")
    assert update.getItemTobeSend()[1] in [EDITED+"百合", EDITED+"佐天泪子"]

    # 2. test when new items exist but is deleted
    rs.set(NEWITEM+"newitem1", "newitem1")
    rs.set(NEWITEM+"newitem2", "newitem2")
    assert update.getItemTobeSend()[1] in [EDITED+"佐天泪子", EDITED+"百合"]

    # 3. test when new items existed and existed in mb web pages
    rs.set(NEWITEM+"NTR", "NTR")
    rs.set(NEWITEM+"百合", "百合")

    assert update.getItemTobeSend()[1] in [NEWITEM+"NTR", NEWITEM+"百合"]