Setup basic plugin loader tests

master
Tom Wilson 6 years ago
parent 748a075f1a
commit bb3f176d41

@ -21,7 +21,7 @@ from . import control
chromalog.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) chromalog.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
log = logging.getLogger("shepherd-agent") log = logging.getLogger("shepherd.agent")
@click.group(invoke_without_command=True) @click.group(invoke_without_command=True)
@ -41,7 +41,7 @@ def cli(ctx, default_config_path, local_operation, only_default_layer):
ending with ".toml" will be used. ending with ".toml" will be used.
""" """
version_text = pkg_resources.get_distribution("shepherd") version_text = pkg_resources.get_distribution("shepherd")
log.info(F"Shepherd Agent {version_text}") log.info(F"Shepherd Agent [{version_text}]")
if ctx.invoked_subcommand == "template": if ctx.invoked_subcommand == "template":
return return

@ -0,0 +1,12 @@
from configspec import *
from shepherd import PluginInterface
interface = PluginInterface()
confspec = ConfigSpecification()
confspec.add_spec("spec1", StringSpec())
confspec2 = ConfigSpecification()
confspec2.add_spec("spec2", StringSpec())
interface.register_confspec(confspec2)

@ -0,0 +1,11 @@
import pytest
from shepherd.agent import plugin
def test_simple_plugin_load(request):
# If successful, will load as if it's a custom plugin
interface = plugin.load_plugin("simpletestplugin", request.fspath.dirname)
# Should prefer the confspec actually registered
assert "spec2" in interface.confspec.spec_dict
print(interface)
Loading…
Cancel
Save