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
评论列表
文章目录