mirror of https://gitlab.com/KKlochko/tui-rsync
parent
594d9dea3f
commit
f3c600bb8f
@ -0,0 +1,16 @@
|
|||||||
|
Feature: Creating the source
|
||||||
|
|
||||||
|
Scenario Outline: Create an new unique backup plan
|
||||||
|
Given the label "<label>"
|
||||||
|
And the path "<source_path>"
|
||||||
|
And the destinations <destinations>
|
||||||
|
And the arguments "<arguments>"
|
||||||
|
When I create the backup plan
|
||||||
|
Then it should be created successfully
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| label | source_path | destinations | arguments |
|
||||||
|
| usb | /mnt/usb | [] | <empty> |
|
||||||
|
| db | /db | ["/backup/db"] | -avuP |
|
||||||
|
| temp | /tmp | ["/backup/tmp1", "/backup/tmp2"] | -avuP --delete |
|
||||||
|
|
@ -0,0 +1,64 @@
|
|||||||
|
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
|
Loading…
Reference in new issue