/
test_addon.py
79 lines (62 loc) · 1.9 KB
/
test_addon.py
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
78
79
# -*- coding: utf-8 -*-
from base import file_exists
from base import generate_answers_ini
from base import run_skeleton_tox_env
import glob
import os.path
import subprocess
base_files = [
".editorconfig",
"setup.py",
"setup.cfg",
"bobtemplate.cfg",
]
addon_files = [
"src/__init__.py",
]
def test_addon(tmpdir, capsys, config):
template = """[variables]
package.description = Dummy package
package.example = True
package.git.disabled = True
author.name = The Plone Collective
author.email = collective@plone.org
author.github.user = collective
plone.version = {version}
""".format(
version=config.version,
)
generate_answers_ini(tmpdir.strpath, template)
config.template = "addon"
config.package_name = "collective.task"
with capsys.disabled():
result = subprocess.call(
[
"mrbob",
"-O",
config.package_name,
"bobtemplates.plone:" + config.template,
"--config",
"answers.ini",
"--non-interactive",
],
cwd=tmpdir.strpath,
)
assert result == 0
generated_files = glob.glob(
tmpdir.strpath + "/" + config.package_name + "/*",
)
length = len(tmpdir.strpath + "/" + config.package_name + "/")
generated_files = [f[length:] for f in generated_files]
required_files = base_files + addon_files
assert required_files <= generated_files
base_path = tmpdir.strpath + "/" + config.package_name
assert file_exists(base_path, "/src/collective/task/configure.zcml")
wd = os.path.abspath(
os.path.join(tmpdir.strpath, config.package_name),
)
with capsys.disabled():
returncode = run_skeleton_tox_env(wd, config)
assert (
returncode == 0
), "The tests inside the generated package are failing, please check the output above!"