mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 22:27:47 +00:00
65 lines
2.5 KiB
Python
65 lines
2.5 KiB
Python
import unittest
|
|
from unittest.mock import Mock, patch
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from tests.helpers import TestContext, temporary_root
|
|
from tutor import plugins
|
|
from tutor.commands.plugins import plugins_command
|
|
|
|
|
|
class PluginsTests(unittest.TestCase):
|
|
def test_plugins_help(self) -> None:
|
|
runner = CliRunner()
|
|
result = runner.invoke(plugins_command, ["--help"])
|
|
self.assertEqual(0, result.exit_code)
|
|
self.assertIsNone(result.exception)
|
|
|
|
def test_plugins_printroot(self) -> None:
|
|
with temporary_root() as root:
|
|
context = TestContext(root)
|
|
runner = CliRunner()
|
|
result = runner.invoke(plugins_command, ["printroot"], obj=context)
|
|
self.assertEqual(0, result.exit_code)
|
|
self.assertIsNone(result.exception)
|
|
self.assertTrue(result.output)
|
|
|
|
@patch.object(plugins.BasePlugin, "iter_installed", return_value=[])
|
|
def test_plugins_list(self, _iter_installed: Mock) -> None:
|
|
with temporary_root() as root:
|
|
context = TestContext(root)
|
|
runner = CliRunner()
|
|
result = runner.invoke(plugins_command, ["list"], obj=context)
|
|
self.assertEqual(0, result.exit_code)
|
|
self.assertIsNone(result.exception)
|
|
self.assertFalse(result.output)
|
|
_iter_installed.assert_called()
|
|
|
|
def test_plugins_install_not_found_plugin(self) -> None:
|
|
with temporary_root() as root:
|
|
context = TestContext(root)
|
|
runner = CliRunner()
|
|
result = runner.invoke(
|
|
plugins_command, ["install", "notFound"], obj=context
|
|
)
|
|
self.assertEqual(1, result.exit_code)
|
|
self.assertTrue(result.exception)
|
|
|
|
def test_plugins_enable_not_installed_plugin(self) -> None:
|
|
with temporary_root() as root:
|
|
context = TestContext(root)
|
|
runner = CliRunner()
|
|
result = runner.invoke(plugins_command, ["enable", "notFound"], obj=context)
|
|
self.assertEqual(1, result.exit_code)
|
|
self.assertTrue(result.exception)
|
|
|
|
def test_plugins_disable_not_installed_plugin(self) -> None:
|
|
with temporary_root() as root:
|
|
context = TestContext(root)
|
|
runner = CliRunner()
|
|
result = runner.invoke(
|
|
plugins_command, ["disable", "notFound"], obj=context
|
|
)
|
|
self.assertEqual(0, result.exit_code)
|
|
self.assertFalse(result.exception)
|