from app.services import category_service from app.schemas.category import CategoryCreate def test_create_and_get_category(db): cat = category_service.create_category(db, CategoryCreate(name="Electrónica", description="Productos electrónicos")) assert cat.id is not None assert cat.name == "Electrónica" found = category_service.get_category(db, cat.id) assert found is not None assert found.name == "Electrónica" def test_list_categories(db): category_service.create_category(db, CategoryCreate(name="Cat1")) category_service.create_category(db, CategoryCreate(name="Cat2")) cats = category_service.get_categories(db) assert len(cats) == 2 def test_update_category(db): cat = category_service.create_category(db, CategoryCreate(name="Original")) from app.schemas.category import CategoryUpdate updated = category_service.update_category(db, cat.id, CategoryUpdate(name="Modificado")) assert updated.name == "Modificado" def test_delete_category(db): cat = category_service.create_category(db, CategoryCreate(name="ToDelete")) ok = category_service.delete_category(db, cat.id) assert ok is True assert category_service.get_category(db, cat.id) is None