本文整理汇总了Python中inbox.models.backends.imap.ImapUid.mark_deleted方法的典型用法代码示例。如果您正苦于以下问题:Python ImapUid.mark_deleted方法的具体用法?Python ImapUid.mark_deleted怎么用?Python ImapUid.mark_deleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inbox.models.backends.imap.ImapUid
的用法示例。
在下文中一共展示了ImapUid.mark_deleted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_soft_delete
# 需要导入模块: from inbox.models.backends.imap import ImapUid [as 别名]
# 或者: from inbox.models.backends.imap.ImapUid import mark_deleted [as 别名]
def test_soft_delete(db, config):
from inbox.models import Folder, Message
from inbox.models.backends.imap import ImapUid
f = Folder(name='DOES NOT EXIST', account_id=ACCOUNT_ID)
db.session.add(f)
db.session.flush()
m = Message()
m.namespace_id = NAMESPACE_ID
m.thread_id = 1
m.received_date = datetime.datetime.utcnow()
m.size = 0
m.sanitized_body = ""
m.snippet = ""
u = ImapUid(message=m, account_id=ACCOUNT_ID, folder_id=f.id,
msg_uid=9999, extra_flags="")
db.session.add_all([m, u])
f.mark_deleted()
u.mark_deleted()
db.session.commit()
m_id = m.id
# bypass custom query method to confirm creation
db.new_session(ignore_soft_deletes=False)
f = db.session.query(Folder).filter_by(name='DOES NOT EXIST').one()
assert f, "Can't find Folder object"
assert f.deleted_at is not None, "Folder not marked as deleted"
db.new_session(ignore_soft_deletes=True)
with pytest.raises(NoResultFound):
db.session.query(Folder).filter(Folder.name == 'DOES NOT EXIST').one()
count = db.session.query(Folder).filter(
Folder.name == 'DOES NOT EXIST').count()
assert count == 0, "Shouldn't find any deleted folders!"
m = db.session.query(Message).filter_by(id=m_id).one()
assert not m.imapuids, "imapuid was deleted!"