Update the Source to BackupPlan component and shared.

This commit is contained in:
2025-01-05 19:27:24 +02:00
parent c67dc14003
commit 594d9dea3f
50 changed files with 80 additions and 1329 deletions
-58
View File
@@ -1,58 +0,0 @@
from behave import given, when, then
from peewee import IntegrityError
from tui_rsync.models.models import create_tables
from tui_rsync.models.models import Source
import json
@given('the label "{label}"')
def given_source_label(context, label):
create_tables()
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 add the source')
def add_source(context):
try:
context.source = Source.create_save(
context.label,
context.source_path,
context.destinations,
context.args,
)
context.source = Source.get_source(context.label)
except IntegrityError:
context.exception_raised = True
else:
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')
def path_has_added(context):
assert context.exception_raised == False
assert context.source.label == context.label
assert context.source.source.path == context.source_path
assert compare_destinations(
context.source.get_destinations(),
context.destinations
)
assert context.source.args.command == context.args
-28
View File
@@ -1,28 +0,0 @@
from behave import given, when, then
from peewee import IntegrityError
from tui_rsync.models.models import create_tables
from tui_rsync.models.models import Path
@given('a path "{path_str}"')
def given_path(context, path_str):
create_tables()
context.path_str = path_str
@when('I add the path to the database')
def add_path(context):
try:
context.path = Path.create(path=context.path_str)
except IntegrityError:
context.exception_raised = True
else:
context.exception_raised = False
@then('the path should be added successfully')
def path_has_added(context):
assert context.path.path == context.path_str
assert context.exception_raised == False
@then('the exception should occur')
def path_has_not_added(context):
assert context.exception_raised == True