ADDED test/config_types.py Index: test/config_types.py ================================================================== --- test/config_types.py +++ test/config_types.py @@ -0,0 +1,38 @@ +# type: test +# title: type mapping +# description: test for common types in config: +# config: +# { name: s1, type: string, value: 1 } +# { name: s2, type: boolean, value: 1 } +# { name: s3, type: longstr, value: … } +# { name: s4, type: number, value: 1 } +# { name: s5, type: decimal, value: 1 } +# { name: s6, type: choice, value: 1 } +# version: 0.1 +# +# Do all the settings! + +import pytest +import pluginconf + +pluginconf.config_opt_type_map.update({ + "decimal": "int", +}) + + +@pytest.fixture +def config(): + return pluginconf.plugin_meta(fn=__file__)["config"] + +@pytest.mark.parametrize("nam,typ", [ + ("s1", "str"), + ("s2", "bool"), + ("s3", "text"), + ("s4", "int"), + ("s5", "int"), + ("s6", "select"), +]) +def check_types(config, nam, typ): + for opt in config: + if opt["name"] == nam: + assert opt["type"] == typ ADDED test/depends.py Index: test/depends.py ================================================================== --- test/depends.py +++ test/depends.py @@ -0,0 +1,54 @@ +# api: foobar +# type: test +# title: depends: checks +# description: basic dependency resolving +# version: 2.5 +# depends: core >= 2.0, existing +# +# Simulates some plugins to check against + + +import pytest +import pluginconf +import pluginconf.depends +import logging +logging.basicConfig(level=logging.DEBUG) + + +@pytest.fixture +def check(): + deps = pluginconf.depends.DependencyValidation( + add={"core": 2.555, "config": 2.0, "existing": 0.1}, + core=["IMPLICIT"], + ) + deps.api = ["python", "foobar"] + return deps + +@pytest.fixture +def update_stream(): # …/repo.json/streamtuner2/contrib/*.py + return [ + { + "$name": "new-plugin", + "$type": "x-py", + "$dist": "app/foobar", + "$file": "http://...", + "api": "foobar", + "version": "2.0", + "title": "new", + "config": "-", + "priority": "deprecated", + } + ] + +@pytest.fixture +def mod1(): + return pluginconf.plugin_meta(filename=__file__) + + +def self_depends(check, mod1): + assert check.depends(mod1) + +def self_api_match(check, update_stream): + print(check.have) + assert check.valid(update_stream[0]) + Index: test/pyz.py ================================================================== --- test/pyz.py +++ test/pyz.py @@ -11,14 +11,15 @@ import os.path import pytest import pluginconf sys.path.insert(0, f"{os.path.dirname(__file__)}/.pyz.pyz") -os.chdir(os.path.dirname(__file__)) +#os.chdir(os.path.dirname(__file__)) @pytest.fixture def init(): + print(pluginconf.module_base) pluginconf.module_base = ["config"] # must be one of the .pyz-contained modules (should be a dir/submodule for real uses) pluginconf.plugin_base = ["inner"] # relative, must declare __path__, can't be __main__.py @pytest.fixture def pmd(): @@ -35,5 +36,10 @@ assert pmd["type"] == "pyz" assert pmd["category"] == "complex" assert pmd["title"] == "pyz module" assert pmd["config"][0]["name"] == "relation" assert pmd["state"] == "alpha" + +#def tearDown(): +# pass#pluginconf.plugin_base = [".", "test", os.path.dirname(__file__), "."] +# #pluginconf.module_base = "all_plugin_meta" +# sys.path.pop(0) ADDED test/setup.py Index: test/setup.py ================================================================== --- test/setup.py +++ test/setup.py @@ -0,0 +1,36 @@ +# type: test +# title: setup() +# description: probe for prepared attributes +# version: 0.7 +# +# distutils bad + +import pytest +import pluginconf +import pluginconf.setup +import setuptools + + +@pytest.fixture +def pmd(): + return pluginconf.plugin_meta(module="pluginconf") + +attr = {} +def _record(**kwargs): + attr.update(kwargs) + + +def attributes(mocker, pmd): + + stop = mocker.patch('setuptools.setup', _record) + pluginconf.setup.setup( + fn="pluginconf/__init__.py", + ) + + assert attr["classifiers"] + assert attr["project_urls"] + assert attr["packages"] == ['pluginconf', 'test'] + assert attr["long_description_content_type"] == 'text/markdown' + assert attr["license"] == 'PD' + assert attr["keywords"] == 'config' + assert attr["long_description"].find("meta data") > 0