-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e70df6
commit 6a97a68
Showing
3 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from unittest import TestCase | ||
from click.core import Command as ClickCommand | ||
from opnsense_cli.autoloader.click_command import ClickCommandAutoloader | ||
from opnsense_cli.cli import cli | ||
from unittest.mock import patch | ||
import os | ||
|
||
|
||
class TestClickCommandAutoloader(TestCase): | ||
def setUp(self): | ||
self._autoloader = ClickCommandAutoloader(cli) | ||
self._script_dir = os.path.dirname(os.path.realpath(__file__)) | ||
self._commands_dir = f"{self._script_dir}/../../opnsense_cli/commands" | ||
|
||
@patch("opnsense_cli.autoloader.click_command.os.walk") | ||
def test_autoload_commands(self, os_walk_mock): | ||
os_walk_mock.return_value = [ | ||
(f"{self._commands_dir}/version", ["__pycache__"], ["__init__.py"]), | ||
(f"{self._commands_dir}/version/__pycache__", [], ["__init__"]), | ||
] | ||
result = self._autoloader.autoload("opnsense_cli.commands.version") | ||
|
||
self.assertIsInstance(result, ClickCommand) |