<filename>tests/commands/test_command.py<gh_stars>0
"""Commands base class unit tests."""
from argparse import ArgumentParser
from argparse import Namespace
from pytest import mark

from cchoir.commands.command import Command


class _DeployCommand(Command):

    name = 'deploy'

    def configure(self, parser: ArgumentParser) -> None:
        parser.add_argument('--update', action='store_true')

    async def run(self, arguments: Namespace) -> None:
        assert arguments.update


class _BackupCommand(Command):
    name = 'backup'

    def configure(self, parser: ArgumentParser) -> None:
        parser.add_argument('--full', action='store_true')

    async def run(self, arguments: Namespace) -> None:
        assert arguments.full


@mark.asyncio
async def test_run_command() -> None:
    """Check Command.run_command correctly configures & run given commands."""
    await Command.run_command(['deploy', '--update'], _DeployCommand(), _BackupCommand())
    await Command.run_command(['backup', '--full'], _DeployCommand(), _BackupCommand())

<filename>tests/commands/test_command.py<gh_stars>0
"""Commands base class unit tests."""
from argparse import ArgumentParser
from argparse import Namespace
from pytest import mark

from cchoir.commands.command import Command


class _DeployCommand(Command):

    name = 'deploy'

    def configure(self, parser: ArgumentParser) -> None:
        parser.add_argument('--update', action='store_true')

    async def run(self, arguments: Namespace) -> None:
        assert arguments.update


class _BackupCommand(Command):
    name = 'backup'

    def configure(self, parser: ArgumentParser) -> None:
        parser.add_argument('--full', action='store_true')

    async def run(self, arguments: Namespace) -> None:
        assert arguments.full


@mark.asyncio
async def test_run_command() -> None:
    """Check Command.run_command correctly configures & run given commands."""
    await Command.run_command(['deploy', '--update'], _DeployCommand(), _BackupCommand())
    await Command.run_command(['backup', '--full'], _DeployCommand(), _BackupCommand())

Commands base class unit tests. Check Command.run_command correctly configures & run given commands.