Debian Codegraph @

tests/plugin_info_test.py

raw
1 import sys
2 from io import StringIO
3 from pathlib import Path
4
5 import pytest
6
7 from errbot.plugin_info import PluginInfo
8
9 plugfile_base = Path(__file__).absolute().parent / "config_plugin"
10 plugfile_path = plugfile_base / "config.plug"
11
12
13 def test_load_from_plugfile_path():
14 pi = PluginInfo.load(plugfile_path)
15 assert pi.name == "Config"
16 assert pi.module == "config"
17 assert pi.doc is None
18 assert pi.python_version == (3, 0, 0)
19 assert pi.errbot_minversion is None
20 assert pi.errbot_maxversion is None
21
22
23 @pytest.mark.parametrize(
24 "test_input,expected",
25 [
26 ("2", (2, 0, 0)),
27 ("2+", (3, 0, 0)),
28 ("3", (3, 0, 0)),
29 ("1.2.3", (1, 2, 3)),
30 ("1.2.3-beta", (1, 2, 3)),
31 ],
32 )
33 def test_python_version_parse(test_input, expected):
34 f = StringIO(
35 """
36 [Core]
37 Name = Config
38 Module = config
39
40 [Python]
41 Version = %s
42 """
43 % test_input
44 )
45
46 assert PluginInfo.load_file(f, None).python_version == expected
47
48
49 def test_doc():
50 f = StringIO(
51 """
52 [Core]
53 Name = Config
54 Module = config
55
56 [Documentation]
57 Description = something
58 """
59 )
60
61 assert PluginInfo.load_file(f, None).doc == "something"
62
63
64 def test_errbot_version():
65 f = StringIO(
66 """
67 [Core]
68 Name = Config
69 Module = config
70 [Errbot]
71 Min = 1.2.3
72 Max = 4.5.6-beta
73 """
74 )
75 info = PluginInfo.load_file(f, None)
76 assert info.errbot_minversion == (1, 2, 3, sys.maxsize)
77 assert info.errbot_maxversion == (4, 5, 6, 0)