2022-04-29 09:26:55 -04:00
|
|
|
"""Test that a plugin can be loaded by directory.
|
|
|
|
|
|
|
|
This file is copied to a location with the name "directory.py",
|
|
|
|
and is then loaded from within the `test_cli.py` code.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os.path
|
|
|
|
|
2022-04-30 21:46:09 -04:00
|
|
|
import dotbot
|
|
|
|
|
2022-04-29 09:26:55 -04:00
|
|
|
|
|
|
|
class Directory(dotbot.Plugin):
|
|
|
|
def can_handle(self, directive):
|
|
|
|
return directive == "plugin_directory"
|
|
|
|
|
|
|
|
def handle(self, directive, data):
|
|
|
|
self._log.debug("Attempting to get options from Context")
|
|
|
|
options = self._context.options()
|
|
|
|
if len(options.plugin_dirs) != 1:
|
2022-04-30 21:42:36 -04:00
|
|
|
self._log.debug(
|
|
|
|
"Context.options.plugins length is %i, expected 1" % len(options.plugins)
|
|
|
|
)
|
2022-04-29 09:26:55 -04:00
|
|
|
return False
|
|
|
|
|
|
|
|
with open(os.path.abspath(os.path.expanduser("~/flag")), "w") as file:
|
|
|
|
file.write("directory plugin loading works")
|
|
|
|
return True
|