Add tests for the remove all backup plans service.

This commit is contained in:
2025-01-28 10:53:02 +02:00
parent 2874dc76ad
commit cabcde00c7
2 changed files with 32 additions and 1 deletions
+17
View File
@@ -1,6 +1,7 @@
from behave import given, when, then
import json
from tui_rsync.core.components.backup_plan.application.services import RemoveAllBackupPlansService
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
@@ -52,6 +53,17 @@ def when_remove_backup_plan_with_id(context, backup_plan_id):
context.exception_raised = False
@when('I remove all backup plans')
def when_remove_all_backup_plans(context):
try:
context.backup_plan_service = context.injector.get(RemoveAllBackupPlansService)
context.result_value = context.backup_plan_service.remove_all()
except CommandException as e:
context.exception_raised = True
else:
context.exception_raised = False
@when('I read the backup plan with id="{backup_plan_id}"')
def when_read_backup_plan_with_id(context, backup_plan_id):
try:
@@ -91,3 +103,8 @@ def then_cli_executed_successfully(context, result):
assert context.exception_raised
@then('the result value should be "{result}"')
def then_cli_executed_successfully(context, result):
assert result == str(context.result_value)