Artifact bdb0475b8cb79ce888f81261e501db9622e5150f7dca1094b638f2110b230523:


# type: test
# title: bind loader
# description: simple loader mechanism
# version: 0.1
# 
# Utilize plugins/


import pytest
import logging
logging.basicConfig(level=logging.DEBUG)
import pluginconf
print(pluginconf.plugin_base)
import pluginconf.bind


def init(reset):
#    pluginconf.plugin_base = []
    import test.plugins
    pluginconf.bind.base(test.plugins)
    assert "test.plugins" in pluginconf.plugin_base
    assert test.plugins.__path__ != []

def test_first():
    assert pluginconf.plugin_meta(module="first").title == "first plugin"

def find_plugins():
    assert len(pluginconf.bind.find(type="stub")) == 3

def config_set():
    conf = {
        "first_run": 1,
        "plugins": {
        },
    }
    pluginconf.bind.defaults(conf)
    assert conf["injected"] is True  # converted from "1"
    assert conf["plugins"]["core"] == True  # priority core

def load_first():
    conf = {
        "plugins": {
            "first": True,
        },
    }
    for mod in pluginconf.bind.load_enabled(conf):
        assert mod.init

def context():
    with pluginconf.bind.isolated("test.plugins") as ext:
        assert len(ext.find(type="stub")) == 3
        assert ext.run.init() == 4

def tearDown(reset):
    pass