test_crud.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:catchpy 作者: nmaekawa 项目源码 文件源码
def test_import_anno_ok_2(wa_image):
    catcha = wa_image

    now = datetime.now(tz.tzutc())

    # import first because CRUD.create changes created time in input
    catcha['id'] = 'naomi-xx-imported'
    resp = CRUD.import_annos([catcha])
    x2 = Anno._default_manager.get(pk=catcha['id'])
    assert x2 is not None
    assert Anno._default_manager.count() == 1

    # x2 was created more in the past? import preserves created date?
    delta = timedelta(hours=25)
    assert x2.created < (now - delta)

    # about to create
    catcha['id'] = 'naomi-xx'
    x1 = CRUD.create_anno(catcha)
    assert x1 is not None
    assert Anno._default_manager.count() == 2

    # x1 was created less than 1m ago?
    delta = timedelta(minutes=1)
    assert (now - delta) < x1.created
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号