-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_packages_full.py
94 lines (74 loc) · 2.74 KB
/
test_packages_full.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
URANIUM_PY = """
def main(build):
build.packages.install("nose")
import nose
assert nose is not None
""".strip()
URANIUM_PY_UPDATE = """
def main(build):
build.packages.install("nose" {0})
import nose
print(nose.__version__)
print("test")
""".strip()
from uranium.scripts import execute_script
from .conftest import URANIUM_SOURCE_ROOT
def test_install(tmpdir):
# we need to create a virtualenv
tmpdir.join("ubuild.py").write(URANIUM_PY)
code, out, err = execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
print("stdout:\n" + str(out))
print("stderr:\n" + str(err))
assert code == 0
def test_package_cache(tmpdir):
""" don't event attempt to call pip, if a package already exists. """
tmpdir.join("ubuild.py").write(URANIUM_PY)
execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
code, out, err = execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
print(out)
print(err)
assert "Requirement already satisified" not in str(out)
assert code == 0
def test_update(tmpdir):
""" update should update versions to the latest. """
hard_version = URANIUM_PY_UPDATE.format(',version="==1.3.1"')
tmpdir.join("ubuild.py").write(hard_version)
status, out, err = execute_script("uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath)
assert "1.3.1" in out.decode("utf-8")
no_version = URANIUM_PY_UPDATE.format('')
tmpdir.join("ubuild.py").write(no_version)
status, out, err = execute_script("uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath)
assert "1.3.1" in out.decode("utf-8")
update_version = URANIUM_PY_UPDATE.format(',upgrade=True')
tmpdir.join("ubuild.py").write(update_version)
status, out, err = execute_script("uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath)
assert "1.3.1" in out.decode("utf-8")
def test_versions_dict_updated(tmpdir):
""" the versions dict should be updated once a version is installed. """
UBUILD = """
def main(build):
build.packages.install("nose")
print(build.packages.versions["nose"])
print("fooo")
""".strip()
# we need to create a virtualenv
tmpdir.join("ubuild.py").write(UBUILD)
code, out, err = execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
print("stdout:\n" + str(out))
print("stderr:\n" + str(err))
assert code == 0