File test/depends.py artifact 3267defa9d part of check-in 3be9f23c57


# 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.Check(
        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])