Compare commits
5 commits
79ec53f148
...
9dd6c0b5c2
Author | SHA1 | Date | |
---|---|---|---|
|
9dd6c0b5c2 | ||
|
8d94c6ec1a | ||
|
2294ac78f8 | ||
|
e2c455213c | ||
|
8bd46a6549 |
5 changed files with 52 additions and 3 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
@ -47,11 +47,14 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
python -m tox
|
python -m tox
|
||||||
python -m tox -e coverage_report
|
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:
|
fmt:
|
||||||
name: Format
|
name: Format
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: psf/black@stable
|
- uses: psf/black@stable
|
||||||
- uses: isort/isort-action@v1
|
- uses: isort/isort-action@v1
|
||||||
|
|
4
codecov.yml
Normal file
4
codecov.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
coverage:
|
||||||
|
status:
|
||||||
|
project: off
|
||||||
|
patch: off
|
|
@ -18,7 +18,10 @@ class Dispatcher:
|
||||||
):
|
):
|
||||||
self._log = Messenger()
|
self._log = Messenger()
|
||||||
self._setup_context(base_directory, options)
|
self._setup_context(base_directory, options)
|
||||||
plugins = plugins or []
|
if plugins == None:
|
||||||
|
plugins = Plugin.__subclasses__()
|
||||||
|
else:
|
||||||
|
plugins = plugins or []
|
||||||
self._plugins = [plugin(self._context) for plugin in plugins]
|
self._plugins = [plugin(self._context) for plugin in plugins]
|
||||||
self._only = only
|
self._only = only
|
||||||
self._skip = skip
|
self._skip = skip
|
||||||
|
|
17
tests/dotbot_plugin_dispatch.py
Normal file
17
tests/dotbot_plugin_dispatch.py
Normal 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
22
tests/test_dispatcher.py
Normal 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"))
|
Loading…
Reference in a new issue