mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-06 07:30:40 +00:00
fix: unit tests with v1 plugin installed
When a v1 plugin was installed, several things were happening regarding tests: 1. v1 plugin loading was happening despite the TUTOR_IGNORE_ENTRYPOINT_PLUGINS environment variable. 2. the CORE_READY event was not triggered because it was happening just once at import time. This was causing some tests to incorrectly load the MFE plugin.
This commit is contained in:
parent
d9486018a2
commit
34c8eeeaec
@ -16,16 +16,9 @@ class JobsTests(unittest.TestCase):
|
||||
config = tutor_config.load_full(root)
|
||||
runner = context.job_runner(config)
|
||||
jobs.initialise(runner)
|
||||
|
||||
output = mock_stdout.getvalue().strip()
|
||||
service = re.search(r"Service: (\w*)", output)
|
||||
commands = re.search(r"(-----)([\S\s]+)(-----)", output)
|
||||
assert service is not None
|
||||
assert commands is not None
|
||||
self.assertTrue(output.startswith("Initialising all services..."))
|
||||
self.assertTrue(output.endswith("All services initialised."))
|
||||
self.assertEqual(service.group(1), "mysql")
|
||||
self.assertTrue(commands.group(2))
|
||||
|
||||
def test_create_user_command_without_staff(self) -> None:
|
||||
command = jobs.create_user_command("superuser", False, "username", "email")
|
||||
|
@ -14,12 +14,13 @@ from tutor.commands.k8s import k8s
|
||||
from tutor.commands.local import local
|
||||
from tutor.commands.plugins import plugins_command
|
||||
|
||||
# Everyone on board
|
||||
hooks.Actions.CORE_READY.do()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
# Everyone on board
|
||||
# Note that this action should not be triggered in the module scope, because it
|
||||
# makes it difficult for tests to rollback changes.
|
||||
hooks.Actions.CORE_READY.do()
|
||||
cli() # pylint: disable=no-value-for-parameter
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
@ -25,8 +25,9 @@ def _discover_entrypoint_plugins() -> None:
|
||||
Discover all plugins that declare a "tutor.plugin.v1" entrypoint.
|
||||
"""
|
||||
with hooks.Contexts.PLUGINS.enter():
|
||||
for entrypoint in pkg_resources.iter_entry_points("tutor.plugin.v1"):
|
||||
discover_package(entrypoint)
|
||||
if "TUTOR_IGNORE_ENTRYPOINT_PLUGINS" not in os.environ:
|
||||
for entrypoint in pkg_resources.iter_entry_points("tutor.plugin.v1"):
|
||||
discover_package(entrypoint)
|
||||
|
||||
|
||||
def discover_module(path: str) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user