def test_remove_in_2step(wa_list): # insert a reply wa_list.append(make_wa_object( age_in_hours=8, reply_to=wa_list[0]['id'])) # add a deleted wa_list[1]['platform']['deleted'] = True original_total = len(wa_list) # import catcha list import_resp = CRUD.import_annos(wa_list) assert int(import_resp['original_total']) == original_total assert int(import_resp['total_success']) == original_total assert int(import_resp['total_failed']) == 0 # delete annotations (not all soft-deleted) delete_resp = CRUD.delete_annos( context_id=wa_list[1]['platform']['context_id']) assert int(delete_resp['failed']) == 0 # discount the deleted and reply assert int(delete_resp['succeeded']) == (original_total -2) anno_list = CRUD.select_annos( context_id=wa_list[0]['platform']['context_id'], is_copy=False ) # didn't true-delete anything yet assert len(anno_list) == original_total # delete annotations (true-delete) delete2_resp = CRUD.delete_annos( context_id=wa_list[1]['platform']['context_id']) assert int(delete2_resp['failed']) == 0 assert int(delete2_resp['succeeded']) == original_total anno_list = CRUD.select_annos( context_id=wa_list[0]['platform']['context_id'], is_copy=False ) # true-delete all annotations assert len(anno_list) == 0
def handle(self, *args, **kwargs): context_id = kwargs['context_id'] collection_id = kwargs['collection_id'] platform_name = kwargs['platform_name'] userid_list = None username_list = None if kwargs['userid_list']: userid_list = kwargs['userid_list'].strip().split(',') if kwargs['username_list']: username_list = kwargs['username_list'].strip().split(',') # search by params result = CRUD.delete_annos(context_id=context_id, collection_id=collection_id, platform_name=platform_name, userid_list=userid_list, username_list=username_list) print(json.dumps(result, indent=4))