# 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 *
    # 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+"百合"]

    _deletePrefix(EDITED)
    _deletePrefix(NEWITEM)


def test_item_deleted():
    assert update.item_deleted("gjlsjirjl")
    assert not update.item_deleted("NTR")


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


# 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 *

    # 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+"百合"]

    _deletePrefix(EDITED)
    _deletePrefix(NEWITEM)


def test_item_deleted():
    assert update.item_deleted("gjlsjirjl")
    assert not update.item_deleted("NTR")


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)