Add the tests for the read query.

dev
KKlochko 3 months ago
parent 476a0ef8cf
commit b999975695

@ -0,0 +1,18 @@
Feature: Deleting a backup plan with the CLI
@fixture.injector
@fixture.in_memory_database
@fixture.seeds
@fixture.cli
Scenario Outline: Deleting a backup plan with the CLI
Given the CLI arguments are "<arguments>"
And I have a backup plan with id="<existing_backup_plan_id>"
When I run the CLI
Then the CLI executed with "<result>"
Examples:
| arguments | existing_backup_plan_id | result | description |
| plans show one -i 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | success | delete an existing plan |
| plans show one -i 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | delete a non-existing plan |

@ -15,21 +15,3 @@ Feature: Creating a backup plan
| usb | /mnt/usb | [] | | usb | /mnt/usb | [] |
| db | /db | ["/backup/db"] | | db | /db | ["/backup/db"] |
| temp | /tmp | ["/backup/tmp1", "/backup/tmp2"] | | temp | /tmp | ["/backup/tmp1", "/backup/tmp2"] |
@fixture.injector
@fixture.in_memory_database
@fixture.backup_plan_service
Scenario Outline: Create an new unique backup plan
Given the label "<label>"
And the path "<source_path>"
And the destinations <destinations>
When I create the backup plan
When I delete the backup plan
Then it should be deleted successfully
Examples:
| label | source_path | destinations |
| usb | /mnt/usb | [] |
| db | /db | ["/backup/db"] |
| temp | /tmp | ["/backup/tmp1", "/backup/tmp2"] |

@ -0,0 +1,14 @@
Feature: Read a backup plan by an id
@fixture.injector
@fixture.in_memory_database
@fixture.seeds
Scenario Outline: Deleting a backup plan with the CLI
Given I have a backup plan with id="<existing_backup_plan_id>"
When I read the backup plan with id="<backup_plan_id>"
Then the result should be "<result>"
Examples:
| backup_plan_id | existing_backup_plan_id | result | description |
| 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | success | delete an existing plan |
| 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | delete a non-existing plan |

@ -5,6 +5,7 @@ from tui_rsync.core.components.backup_plan.application.services.backup_plan_serv
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination
from tui_rsync.core.shared_kernel.components.common import UUID from tui_rsync.core.shared_kernel.components.common import UUID
from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException
from tui_rsync.core.shared_kernel.ports.Exceptions.query_exception import QueryException
@given('the label "{label}"') @given('the label "{label}"')
@ -40,23 +41,23 @@ def add_backup_plan(context):
context.exception_raised = False context.exception_raised = False
@when('I delete the backup plan') @when('I remove the backup plan with id="{backup_plan_id}"')
def add_backup_plan(context): def when_remove_backup_plan_with_id(context, backup_plan_id):
try: try:
context.deleted_result = context.backup_plan_service.delete(context.backup_plan.id) context.backup_plan_service = context.injector.get(BackupPlanService)
context.backup_plan = context.backup_plan_service.get_by_id(context.backup_plan.id) context.backup_plan_service.delete(UUID(backup_plan_id))
except Exception as e: except CommandException as e:
context.exception_raised = True context.exception_raised = True
else: else:
context.exception_raised = False context.exception_raised = False
@when('I remove the backup plan with id="{backup_plan_id}"') @when('I read the backup plan with id="{backup_plan_id}"')
def given_existing_backup_plan_id_seed(context, backup_plan_id): def when_read_backup_plan_with_id(context, backup_plan_id):
try: try:
context.backup_plan_service = context.injector.get(BackupPlanService) context.backup_plan_service = context.injector.get(BackupPlanService)
context.backup_plan_service.delete(UUID(backup_plan_id)) context.backup_plan_service.get_by_id(UUID(backup_plan_id))
except CommandException as e: except QueryException as e:
context.exception_raised = True context.exception_raised = True
else: else:
context.exception_raised = False context.exception_raised = False
@ -80,12 +81,6 @@ def backup_plan_has_added(context):
context.destinations context.destinations
) )
@then('it should be deleted successfully')
def backup_plan_has_deleted(context):
assert context.exception_raised == False
assert context.backup_plan is None
assert context.deleted_result
@then('the result should be "{result}"') @then('the result should be "{result}"')
def then_cli_executed_successfully(context, result): def then_cli_executed_successfully(context, result):

Loading…
Cancel
Save