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"
def test_delete_item(resource): user_id = resource ItemRepo.add_item(description="This is an item", location="inbox", user=user_id) items = ItemRepo.get_all_items() assert len(items) == 1 item_id = str(items[0]["id"]) assert ItemRepo.delete_item(item_id) == True items = ItemRepo.get_all_items() assert len(items) == 0
def item_get(): uid = current_user.get_obj_id() user_items = ItemRepo.get_all_items(user=uid) res = {} res["success"] = True res["data"] = user_items return json.dumps(res)
def test_delete_two_item(resource): user_id = resource ItemRepo.add_item(description="This is an item", location="inbox", user=user_id) ItemRepo.add_item(description="This is another item", location="inbox", user=user_id) items = ItemRepo.get_all_items() assert len(items) == 2 item_id_1 = str(items[0]["id"]) item_id_2 = str(items[1]["id"]) assert ItemRepo.delete_item(item_id_1) == True assert len(ItemRepo.get_all_items()) == 1 assert ItemRepo.delete_item(item_id_2) == True assert len(ItemRepo.get_all_items()) == 0
def test_item_to_project(resource): user_id = resource item = ItemRepo.add_item(description="Thing", location="inbox", user=user_id) project = ItemRepo.item_to_project(item["id"], user_id) assert project is not None assert len(ItemRepo.get_all_items()) == 0 assert project["description"] == "Thing"
def test_store_item(resource): user_id = resource ItemRepo.add_item(description="This is an item", location="inbox", user=user_id) items = ItemRepo.get_all_items() assert len(items) == 1 assert items[0]["description"] == "This is an item" assert items[0]["location"] == "inbox"