File: plugin_info_test.py

package info (click to toggle)
errbot 6.2.0%2Bds-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,848 kB
  • sloc: python: 11,573; makefile: 162; sh: 97
file content (77 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (3)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import sys
from io import StringIO
from pathlib import Path

import pytest

from errbot.plugin_info import PluginInfo

plugfile_base = Path(__file__).absolute().parent / "config_plugin"
plugfile_path = plugfile_base / "config.plug"


def test_load_from_plugfile_path():
    pi = PluginInfo.load(plugfile_path)
    assert pi.name == "Config"
    assert pi.module == "config"
    assert pi.doc is None
    assert pi.python_version == (3, 0, 0)
    assert pi.errbot_minversion is None
    assert pi.errbot_maxversion is None


@pytest.mark.parametrize(
    "test_input,expected",
    [
        ("2", (2, 0, 0)),
        ("2+", (3, 0, 0)),
        ("3", (3, 0, 0)),
        ("1.2.3", (1, 2, 3)),
        ("1.2.3-beta", (1, 2, 3)),
    ],
)
def test_python_version_parse(test_input, expected):
    f = StringIO(
        """
    [Core]
    Name = Config
    Module = config

    [Python]
    Version = %s
    """
        % test_input
    )

    assert PluginInfo.load_file(f, None).python_version == expected


def test_doc():
    f = StringIO(
        """
    [Core]
    Name = Config
    Module = config

    [Documentation]
    Description = something
    """
    )

    assert PluginInfo.load_file(f, None).doc == "something"


def test_errbot_version():
    f = StringIO(
        """
    [Core]
    Name = Config
    Module = config
    [Errbot]
    Min = 1.2.3
    Max = 4.5.6-beta
    """
    )
    info = PluginInfo.load_file(f, None)
    assert info.errbot_minversion == (1, 2, 3, sys.maxsize)
    assert info.errbot_maxversion == (4, 5, 6, 0)