Update the repository to use exception for the delete action.

This commit is contained in:
2025-01-26 14:28:56 +02:00
parent 769edabbd3
commit cae4ce50c5
4 changed files with 19 additions and 15 deletions
+8 -4
View File
@@ -4,6 +4,7 @@ import json
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination
from tui_rsync.core.shared_kernel.components.common import UUID
from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException
@given('the label "{label}"')
@@ -52,10 +53,13 @@ def add_backup_plan(context):
@when('I remove the backup plan with id="{backup_plan_id}"')
def given_existing_backup_plan_id_seed(context, backup_plan_id):
context.backup_plan_service = context.injector.get(BackupPlanService)
context.deleted_result = context.backup_plan_service.delete(UUID(backup_plan_id))
# TODO error value or exception?
context.exception_raised = not context.deleted_result
try:
context.backup_plan_service = context.injector.get(BackupPlanService)
context.backup_plan_service.delete(UUID(backup_plan_id))
except CommandException as e:
context.exception_raised = True
else:
context.exception_raised = False
def compare_destinations(actual: list[Destination], expected: list[str]) -> bool:
+1 -1
View File
@@ -19,7 +19,7 @@ def then_cli_executed_successfully(context, result):
case "success":
assert context.cli_result.exit_code == 0
case "error":
assert context.cli_result.exit_code == 0
assert context.cli_result.exit_code != 0
@then('the CLI output contains "{string}"')