mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
Add the service's test for deleting.
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
Feature: Delete a backup plan
|
||||||
|
|
||||||
|
@fixture.injector
|
||||||
|
@fixture.in_memory_database
|
||||||
|
@fixture.seeds
|
||||||
|
Scenario Outline: Deleting a backup plan with the CLI
|
||||||
|
Given I have a backup plan with id="<existing_backup_plan_id>"
|
||||||
|
When I remove the backup plan with id="<backup_plan_id>"
|
||||||
|
Then the result should be "<result>"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| backup_plan_id | existing_backup_plan_id | result | description |
|
||||||
|
| 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | success | delete an existing plan |
|
||||||
|
| 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | delete a non-existing plan |
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
from behave import given, when, then
|
from behave import given, when, then
|
||||||
import json
|
import json
|
||||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
@given('the label "{label}"')
|
@given('the label "{label}"')
|
||||||
@@ -48,6 +50,14 @@ def add_backup_plan(context):
|
|||||||
context.exception_raised = False
|
context.exception_raised = False
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
||||||
|
|
||||||
def compare_destinations(actual: list[Destination], expected: list[str]) -> bool:
|
def compare_destinations(actual: list[Destination], expected: list[str]) -> bool:
|
||||||
actual_path_set = {destionation.path for destionation in actual}
|
actual_path_set = {destionation.path for destionation in actual}
|
||||||
return actual_path_set == set(expected)
|
return actual_path_set == set(expected)
|
||||||
@@ -71,3 +81,14 @@ def backup_plan_has_deleted(context):
|
|||||||
assert context.exception_raised == False
|
assert context.exception_raised == False
|
||||||
assert context.backup_plan is None
|
assert context.backup_plan is None
|
||||||
assert context.deleted_result
|
assert context.deleted_result
|
||||||
|
|
||||||
|
|
||||||
|
@then('the result should be "{result}"')
|
||||||
|
def then_cli_executed_successfully(context, result):
|
||||||
|
match result:
|
||||||
|
case "success":
|
||||||
|
assert context.exception_raised == False
|
||||||
|
case "error":
|
||||||
|
assert context.exception_raised
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user