mirror of https://gitlab.com/KKlochko/tui-rsync
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
from behave import given, when, then
|
|
import json
|
|
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination
|
|
|
|
|
|
@given('the label "{label}"')
|
|
def given_source_label(context, label):
|
|
context.label = label
|
|
|
|
|
|
@given('the path "{source_path}"')
|
|
def given_source_path(context, source_path):
|
|
context.source_path = source_path
|
|
|
|
|
|
@given('the destinations {destinations_json}')
|
|
def given_source_destinations(context, destinations_json):
|
|
context.destinations = json.loads(destinations_json)
|
|
|
|
|
|
@given('the arguments "{arguments}"')
|
|
def given_source_arguments(context, arguments):
|
|
context.args = arguments
|
|
|
|
if arguments == "<empty>":
|
|
context.args = ""
|
|
|
|
|
|
@when('I create the backup plan')
|
|
def add_source(context):
|
|
try:
|
|
context.backup_plan = BackupPlan(
|
|
label=context.label,
|
|
source=Source(context.source_path),
|
|
destinations=map(lambda path: Destination(path), context.destinations),
|
|
#context.args,
|
|
)
|
|
|
|
#context.source = Source.get_source(context.label)
|
|
except Exception:
|
|
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 path_has_added(context):
|
|
assert context.exception_raised == False
|
|
|
|
assert context.backup_plan.label == context.label
|
|
assert context.backup_plan.source == Source(context.source_path)
|
|
|
|
print(f'{context.backup_plan.destinations=}')
|
|
print(f'{context.destinations=}')
|
|
assert compare_destinations(
|
|
context.backup_plan.destinations,
|
|
context.destinations
|
|
)
|
|
#assert context.source.args.command == context.args
|