|
|
@ -2,6 +2,7 @@ from behave import given, when, then
|
|
|
|
from peewee import IntegrityError
|
|
|
|
from peewee import IntegrityError
|
|
|
|
from tui_rsync.models.models import create_tables
|
|
|
|
from tui_rsync.models.models import create_tables
|
|
|
|
from tui_rsync.models.models import Source
|
|
|
|
from tui_rsync.models.models import Source
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
@given('the label "{label}"')
|
|
|
|
@given('the label "{label}"')
|
|
|
|
def given_source_label(context, label):
|
|
|
|
def given_source_label(context, label):
|
|
|
@ -12,6 +13,10 @@ def given_source_label(context, label):
|
|
|
|
def given_source_path(context, source_path):
|
|
|
|
def given_source_path(context, source_path):
|
|
|
|
context.source_path = 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}"')
|
|
|
|
@given('the arguments "{arguments}"')
|
|
|
|
def given_source_arguments(context, arguments):
|
|
|
|
def given_source_arguments(context, arguments):
|
|
|
|
context.args = arguments
|
|
|
|
context.args = arguments
|
|
|
@ -25,19 +30,29 @@ def add_source(context):
|
|
|
|
context.source = Source.create_save(
|
|
|
|
context.source = Source.create_save(
|
|
|
|
context.label,
|
|
|
|
context.label,
|
|
|
|
context.source_path,
|
|
|
|
context.source_path,
|
|
|
|
[],
|
|
|
|
context.destinations,
|
|
|
|
context.args,
|
|
|
|
context.args,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.source = Source.get_source(context.label)
|
|
|
|
except IntegrityError:
|
|
|
|
except IntegrityError:
|
|
|
|
context.exception_raised = True
|
|
|
|
context.exception_raised = True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
context.exception_raised = False
|
|
|
|
context.exception_raised = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compare_destinations(actual:list, expected: list[str]) -> bool:
|
|
|
|
|
|
|
|
actual_path_set = {destionation.path for destionation in actual}
|
|
|
|
|
|
|
|
return actual_path_set == set(expected)
|
|
|
|
|
|
|
|
|
|
|
|
@then('the source should be added successfully')
|
|
|
|
@then('the source should be added successfully')
|
|
|
|
def path_has_added(context):
|
|
|
|
def path_has_added(context):
|
|
|
|
assert context.exception_raised == False
|
|
|
|
assert context.exception_raised == False
|
|
|
|
|
|
|
|
|
|
|
|
assert context.source.label == context.label
|
|
|
|
assert context.source.label == context.label
|
|
|
|
assert context.source.source.path == context.source_path
|
|
|
|
assert context.source.source.path == context.source_path
|
|
|
|
|
|
|
|
assert compare_destinations(
|
|
|
|
|
|
|
|
context.source.get_destinations(),
|
|
|
|
|
|
|
|
context.destinations
|
|
|
|
|
|
|
|
)
|
|
|
|
assert context.source.args.command == context.args
|
|
|
|
assert context.source.args.command == context.args
|
|
|
|
|
|
|
|
|
|
|
|