Overview
Comment:setup and type map test, fix chdir() - which was redundant and causing more lookup errors in other tests
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 44cb252c3b557dfbdee7b0e313c6adca02bb1c49a5f3e8a618078b63b9f09515
User & Date: mario on 2022-10-26 13:59:45
Other Links: manifest | tags
Context
2022-10-26
14:00
add warning and missing pluginconf. references check-in: 85f6aa649a user: mario tags: trunk
13:59
setup and type map test, fix chdir() - which was redundant and causing more lookup errors in other tests check-in: 44cb252c3b user: mario tags: trunk
13:59
more pylint changes check-in: 7e6847fd5e user: mario tags: trunk
Changes

Added test/config_types.py version [051714d211].













































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 version [10d2104189].













































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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])

Modified test/pyz.py from [0566039b1c] to [c33e5bdbba].

9
10
11
12
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39






import sys
import os.path
import pytest
import pluginconf

sys.path.insert(0, f"{os.path.dirname(__file__)}/.pyz.pyz")
os.chdir(os.path.dirname(__file__))

@pytest.fixture
def init():

    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():
    return pluginconf.plugin_meta(module="inner")

def importy(init):
    import inner as pyz_inner
    #print(pyz_inner.__file__)

def module_list(init):
    assert set(pluginconf.module_list()) & {'__main__', 'config', 'inner'}

def inner_props(pmd):
    assert pmd["type"] == "pyz"
    assert pmd["category"] == "complex"
    assert pmd["title"] == "pyz module"
    assert pmd["config"][0]["name"] == "relation"
    assert pmd["state"] == "alpha"












|



>




















>
>
>
>
>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

import sys
import os.path
import pytest
import pluginconf

sys.path.insert(0, f"{os.path.dirname(__file__)}/.pyz.pyz")
#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():
    return pluginconf.plugin_meta(module="inner")

def importy(init):
    import inner as pyz_inner
    #print(pyz_inner.__file__)

def module_list(init):
    assert set(pluginconf.module_list()) & {'__main__', 'config', 'inner'}

def inner_props(pmd):
    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 version [75184c3ebc].









































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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