1
0
Fork 0
mirror of synced 2024-12-04 13:25:34 -05:00

Compare commits

...

5 commits

Author SHA1 Message Date
Wanimatrix
9dd6c0b5c2
Merge e2c455213c into 8d94c6ec1a 2024-11-28 23:53:16 +00:00
Anish Athalye
8d94c6ec1a Disable coverage status checks 2024-11-21 17:23:21 +05:30
Anish Athalye
2294ac78f8 Update actions 2024-11-21 17:13:19 +05:30
Wouter Franken
e2c455213c Add plugin dispatch test
Add test to verify that a plugin can run dispatch to handle subtasks of
external plugins.
2023-02-19 13:09:00 +01:00
Wouter Franken
8bd46a6549 Fix dispatcher when no plugins are given
When any plugin is using the dispatcher for nested actions it should
pass all plugins again to avoid that any plugin as subtask would be
handled.
Currently this means a lot of plugins are broken because they don't pass
plugins to the dispatcher.

To fix this, take all Plugin subclasses when no plugin is given (we
should at least have the default plugins).
2023-02-19 13:08:41 +01:00
5 changed files with 52 additions and 3 deletions

View file

@ -47,11 +47,14 @@ jobs:
run: |
python -m tox
python -m tox -e coverage_report
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
fmt:
name: Format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: psf/black@stable
- uses: isort/isort-action@v1

4
codecov.yml Normal file
View file

@ -0,0 +1,4 @@
coverage:
status:
project: off
patch: off

View file

@ -18,6 +18,9 @@ class Dispatcher:
):
self._log = Messenger()
self._setup_context(base_directory, options)
if plugins == None:
plugins = Plugin.__subclasses__()
else:
plugins = plugins or []
self._plugins = [plugin(self._context) for plugin in plugins]
self._only = only

View file

@ -0,0 +1,17 @@
"""Test that a plugin can call dispatcher for subtasks.
The plugin calls dispatch with his data.
"""
import os.path
import dotbot
class Dispatch(dotbot.Plugin):
def can_handle(self, directive):
return directive == "dispatch"
def handle(self, directive, data):
dispatcher = dotbot.dispatcher.Dispatcher(self._context.base_directory())
return dispatcher.dispatch(data)

22
tests/test_dispatcher.py Normal file
View file

@ -0,0 +1,22 @@
import os
import shutil
import pytest
def test_plugin_dispatcher(capfd, home, dotfiles, run_dotbot):
"""Verify that plugins can call dispatcher without explicitly specifying plugins."""
dotfiles.makedirs("plugins")
plugin_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "dotbot_plugin_dispatch.py"
)
shutil.copy(plugin_file, os.path.join(dotfiles.directory, "plugins", "dispatch.py"))
dotfiles.write_config(
[
{"dispatch": [{"create": ["~/a"]}]},
]
)
run_dotbot("--plugin-dir", os.path.join(dotfiles.directory, "plugins"))
assert os.path.exists(os.path.join(home, "a"))