Mock command for unit tests.
| 15 | |
| 16 | |
| 17 | class MockCommand(UnifiedCommand): |
| 18 | """Mock command for unit tests.""" |
| 19 | |
| 20 | def __init__( |
| 21 | self, |
| 22 | test_name: str = "test", |
| 23 | test_modes: CommandMode = CommandMode.ALL, |
| 24 | test_hidden: bool = False, |
| 25 | ): |
| 26 | super().__init__() |
| 27 | self._name = test_name |
| 28 | self._description = f"Test command: {test_name}" |
| 29 | self._modes = test_modes |
| 30 | self._aliases = ["t", f"{test_name}_alias"] |
| 31 | self._hidden = test_hidden |
| 32 | self._parameters = [ |
| 33 | CommandParameter( |
| 34 | name="value", |
| 35 | type=str, |
| 36 | help="Test value", |
| 37 | required=False, |
| 38 | ), |
| 39 | ] |
| 40 | self.executed = False |
| 41 | self.last_kwargs = {} |
| 42 | |
| 43 | @property |
| 44 | def name(self) -> str: |
| 45 | """Get command name.""" |
| 46 | return self._name |
| 47 | |
| 48 | @property |
| 49 | def description(self) -> str: |
| 50 | """Get command description.""" |
| 51 | return self._description |
| 52 | |
| 53 | @property |
| 54 | def aliases(self) -> List[str]: |
| 55 | """Get command aliases.""" |
| 56 | return self._aliases |
| 57 | |
| 58 | @property |
| 59 | def modes(self) -> CommandMode: |
| 60 | """Get supported modes.""" |
| 61 | return self._modes |
| 62 | |
| 63 | @property |
| 64 | def hidden(self) -> bool: |
| 65 | """Check if command is hidden.""" |
| 66 | return self._hidden |
| 67 | |
| 68 | @property |
| 69 | def parameters(self) -> List[CommandParameter]: |
| 70 | """Get command parameters.""" |
| 71 | return self._parameters |
| 72 | |
| 73 | async def execute(self, **kwargs) -> CommandResult: |
| 74 | """Execute the test command.""" |
no outgoing calls