mirror of https://gitlab.com/KKlochko/tui-rsync
parent
b999975695
commit
9729f442c2
@ -1,18 +1,46 @@
|
||||
Feature: Deleting a backup plan with the CLI
|
||||
Feature: Show 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
|
||||
Scenario Outline: Show 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 |
|
||||
| arguments | existing_backup_plan_id | result | description |
|
||||
| plans show one -i 8aa59e7e-dc75-459b-beb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be583 | success | show an existing plan |
|
||||
| plans show one -i 8aa59e7e-dc75-459b-aeb5-b710b39be583 | 8aa59e7e-dc75-459b-beb5-b710b39be512 | error | show a non-existing plan |
|
||||
|
||||
@fixture.injector
|
||||
@fixture.in_memory_database
|
||||
@fixture.cli
|
||||
Scenario Outline: Show no backup plans with the CLI
|
||||
Given the CLI arguments are "<arguments>"
|
||||
When I run the CLI
|
||||
Then the CLI executed with "<result>"
|
||||
And the CLI output contains "<result_message>"
|
||||
|
||||
Examples:
|
||||
| arguments | result | result_message | description |
|
||||
| plans show all | success | No backup plans. | shows no plans |
|
||||
|
||||
@fixture.injector
|
||||
@fixture.in_memory_database
|
||||
@fixture.seeds
|
||||
@fixture.cli
|
||||
Scenario Outline: Show backup plans with the CLI
|
||||
Given the CLI arguments are "<arguments>"
|
||||
And I have a backup plan with id="8aa59e7e-dc75-459b-beb5-b710b39be583"
|
||||
When I run the CLI
|
||||
Then the CLI executed with "<result>"
|
||||
And the CLI output contains "8aa59e7e-dc75-459b-beb5-b710b39be583"
|
||||
And the CLI output doesn't contains "<no_message>"
|
||||
|
||||
Examples:
|
||||
| arguments | result | no_message | description |
|
||||
| plans show all | success | No backup plans. | shows plans |
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
from .get_all_backup_plans_query import GetAllBackupBackupPlansQuery
|
||||
from .get_backup_plan_by_id_query import GetBackupBackupPlanByIdQuery
|
||||
from .get_all_backup_plans_query import GetAllBackupPlansQuery
|
||||
from .get_backup_plan_by_id_query import GetBackupPlanByIdQuery
|
||||
from .get_backup_plan_count_query import GetBackupPlanCountQuery
|
||||
|
||||
__all__ = ['GetAllBackupBackupPlansQuery', 'GetBackupBackupPlanByIdQuery']
|
||||
__all__ = ['GetAllBackupPlansQuery', 'GetBackupPlanByIdQuery', 'GetBackupPlanCountQuery']
|
||||
|
@ -0,0 +1,12 @@
|
||||
from tui_rsync.core.ports.orm import DatabaseManagerPort
|
||||
from tui_rsync.infrastructure.orm.dto.dtos import BackupPlanDTO
|
||||
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
|
||||
|
||||
class GetAllBackupBackupPlansQuery:
|
||||
def __init__(self, database_manager: DatabaseManagerPort):
|
||||
self.databaseManager = database_manager
|
||||
|
||||
def execute(self):
|
||||
return (BackupPlanDTO.to_domain(model) for model in BackupPlanModel.select().iterator())
|
@ -0,0 +1,11 @@
|
||||
from tui_rsync.core.ports.orm import DatabaseManagerPort
|
||||
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel
|
||||
|
||||
|
||||
class GetBackupPlanCountQuery:
|
||||
def __init__(self, database_manager: DatabaseManagerPort):
|
||||
self.databaseManager = database_manager
|
||||
|
||||
def execute(self):
|
||||
return BackupPlanModel.select().count()
|
@ -1,3 +1,4 @@
|
||||
from .backup_plan_repository_port import BackupPlanRepositoryPort
|
||||
from .backup_plan_repository import BackupPlanRepository
|
||||
|
||||
__all__ = ['BackupPlanRepositoryPort']
|
||||
__all__ = ['BackupPlanRepositoryPort', 'BackupPlanRepository']
|
||||
|
@ -0,0 +1,5 @@
|
||||
from .backup_plan_service import BackupPlanService
|
||||
from .get_all_backup_plans_service import GetAllBackupPlansService
|
||||
from .get_backup_plan_count_service import GetBackupPlanCountService
|
||||
|
||||
__all__ = ['BackupPlanService', 'GetAllBackupPlansService', 'GetBackupPlanCountService']
|
@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
|
||||
from tui_rsync.core.components.backup_plan.application.queries import GetAllBackupPlansQuery
|
||||
|
||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
||||
|
||||
|
||||
class GetAllBackupPlansService:
|
||||
def __init__(self, get_all_backup_plan_query: GetAllBackupPlansQuery):
|
||||
self.get_all_backup_plan_query = get_all_backup_plan_query
|
||||
|
||||
def get_all(self) -> List[BackupPlan]:
|
||||
return self.get_all_backup_plan_query.execute()
|
@ -0,0 +1,16 @@
|
||||
from typing import List
|
||||
|
||||
from tui_rsync.core.components.backup_plan.application.queries import GetBackupPlanCountQuery
|
||||
|
||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
||||
|
||||
|
||||
class GetBackupPlanCountService:
|
||||
def __init__(self, get_backup_plan_count_query: GetBackupPlanCountQuery):
|
||||
self.get_backup_plan_count_query = get_backup_plan_count_query
|
||||
|
||||
def count(self) -> int:
|
||||
return self.get_backup_plan_count_query.execute()
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
return self.count() == 0
|
Loading…
Reference in new issue