mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
Add the helpers and tests for updating the backup plan.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from behave import given, when, then
|
||||
import json
|
||||
|
||||
from features.support.backup_plan_helpers import compare_destinations, update_backup_plan, compare_backup_plan_fields
|
||||
from features.support.helpers import json_to_dict
|
||||
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
|
||||
@@ -42,6 +44,21 @@ def add_backup_plan(context):
|
||||
context.exception_raised = False
|
||||
|
||||
|
||||
@when('I update the backup plan with id="{backup_plan_id}" and data="{updated_data_json}"')
|
||||
def when_update_backup_plan_with_id(context, backup_plan_id, updated_data_json):
|
||||
try:
|
||||
context.backup_plan_service = context.injector.get(BackupPlanService)
|
||||
context.backup_plan = context.backup_plan_service.get_by_id(UUID(backup_plan_id))
|
||||
|
||||
update_backup_plan(context.backup_plan, json_to_dict(updated_data_json))
|
||||
|
||||
context.backup_plan_service.update(context.backup_plan)
|
||||
except QueryException as e:
|
||||
context.exception_raised = True
|
||||
else:
|
||||
context.exception_raised = False
|
||||
|
||||
|
||||
@when('I remove the backup plan with id="{backup_plan_id}"')
|
||||
def when_remove_backup_plan_with_id(context, backup_plan_id):
|
||||
try:
|
||||
@@ -68,18 +85,13 @@ def when_remove_all_backup_plans(context):
|
||||
def when_read_backup_plan_with_id(context, backup_plan_id):
|
||||
try:
|
||||
context.backup_plan_service = context.injector.get(BackupPlanService)
|
||||
context.backup_plan_service.get_by_id(UUID(backup_plan_id))
|
||||
context.backup_plan = context.backup_plan_service.get_by_id(UUID(backup_plan_id))
|
||||
except QueryException as e:
|
||||
context.exception_raised = True
|
||||
else:
|
||||
context.exception_raised = False
|
||||
|
||||
|
||||
def compare_destinations(actual: list[Destination], expected: list[str]) -> bool:
|
||||
actual_path_set = {destionation.path for destionation in actual}
|
||||
return actual_path_set == set(expected)
|
||||
|
||||
|
||||
@then('it should be created successfully')
|
||||
def backup_plan_has_added(context):
|
||||
assert context.exception_raised == False
|
||||
@@ -108,3 +120,7 @@ def then_cli_executed_successfully(context, result):
|
||||
assert result == str(context.result_value)
|
||||
|
||||
|
||||
@then('the backup_plan must have same field: "{fields_json}"')
|
||||
def backup_plan_has_added(context, fields_json):
|
||||
assert compare_backup_plan_fields(context.backup_plan, json_to_dict(fields_json))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user