def item_to_task(item_id): uid = current_user.get_obj_id() task = ItemRepo.item_to_task(item_id, uid) if not task: return json.dumps({"success": False}) else: return json.dumps({"success": True, "data": task})
def test_item_to_task(resource): user_id = resource ItemRepo.add_item(description="Thing", location="inbox", user=user_id) added_item = ItemRepo.get_all_items()[0] task = ItemRepo.item_to_task(added_item["id"], user_id) # No more items assert len(ItemRepo.get_all_items()) == 0 # Task used to be the item assert task is not None assert task["description"] == "Thing"