Add tests for the remove all backup plans service.

dev
KKlochko 3 months ago
parent 2874dc76ad
commit cabcde00c7

@ -3,7 +3,7 @@ Feature: Delete a backup plan
@fixture.injector @fixture.injector
@fixture.in_memory_database @fixture.in_memory_database
@fixture.seeds @fixture.seeds
Scenario Outline: Deleting a backup plan with the CLI Scenario Outline: Deleting a backup plan
Given I have a backup plan with id="<existing_backup_plan_id>" Given I have a backup plan with id="<existing_backup_plan_id>"
When I remove the backup plan with id="<backup_plan_id>" When I remove the backup plan with id="<backup_plan_id>"
Then the result should be "<result>" Then the result should be "<result>"
@ -12,3 +12,17 @@ Feature: Delete a backup plan
| backup_plan_id | existing_backup_plan_id | result | description | | 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-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 | | 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | delete a non-existing plan |
@fixture.injector
@fixture.in_memory_database
Scenario: Delete no backup plans
When I remove all backup plans
Then the result value should be "False"
@fixture.injector
@fixture.in_memory_database
@fixture.seeds
Scenario: Delete all backup plans
Given I have a backup plan with id="8aa59e7e-dc75-459b-beb5-b710b39be583"
When I remove all backup plans
Then the result value should be "True"

@ -1,6 +1,7 @@
from behave import given, when, then from behave import given, when, then
import json import json
from tui_rsync.core.components.backup_plan.application.services import RemoveAllBackupPlansService
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
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
@ -52,6 +53,17 @@ def when_remove_backup_plan_with_id(context, backup_plan_id):
context.exception_raised = False context.exception_raised = False
@when('I remove all backup plans')
def when_remove_all_backup_plans(context):
try:
context.backup_plan_service = context.injector.get(RemoveAllBackupPlansService)
context.result_value = context.backup_plan_service.remove_all()
except CommandException as e:
context.exception_raised = True
else:
context.exception_raised = False
@when('I read the backup plan with id="{backup_plan_id}"') @when('I read the backup plan with id="{backup_plan_id}"')
def when_read_backup_plan_with_id(context, backup_plan_id): def when_read_backup_plan_with_id(context, backup_plan_id):
try: try:
@ -91,3 +103,8 @@ def then_cli_executed_successfully(context, result):
assert context.exception_raised assert context.exception_raised
@then('the result value should be "{result}"')
def then_cli_executed_successfully(context, result):
assert result == str(context.result_value)

Loading…
Cancel
Save