/
test_ups_commands.py
71 lines (55 loc) · 1.68 KB
/
test_ups_commands.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
#!/usr/bin/env python
'''
test ups.commands
WARNING: these tests will merely print a message and succeed if UPS is not detected.
'''
import os
from ups.commands import install, UpsCommands
from ups.products import Product
ups_version = '5.1.2'
ups_version_underscore = 'v' + ups_version.replace('.','_')
ups_products = os.path.realpath('products')
def setup():
install(ups_version, ups_products)
def test_ups_flavor():
uc = UpsCommands(ups_products)
f = uc.flavor()
assert f
kern = os.uname()[0]
#print ('type(f) = "%s", type(kern) = "%s"' % (type(f), type(kern)))
assert f.startswith(kern)
def test_ups_depend():
'''
Test calling "ups depend".
'''
uc = UpsCommands(ups_products)
prod = Product('ups', ups_version_underscore, flavor=uc.flavor())
assert prod.flavor
text = uc.depend(prod)
assert text.startswith('ups v'), '"%s"'%text
text2 = uc.depend(prod)
assert text == text2, '"%s"\n!=\n"%s"' % (text, text2)
def test_ups_avail():
'''
Test calling "ups depend".
'''
uc = UpsCommands(ups_products)
pds = uc.avail()
for p in pds:
assert not p.repo
print (p.name,p.version,p.flavor,p.quals)
def test_ups_deps():
uc = UpsCommands(ups_products)
tree = uc.full_dependencies()
assert 1 == len(tree.nodes()), tree.nodes()
assert 0 == len(tree.edges()), tree.edges()
for pd in tree.nodes():
assert pd.repo, str(pd)
def test_failure():
uc = UpsCommands(ups_products)
try:
out = uc.call('',cmd='/bin/false')
except RuntimeError as err:
print ('Caught expected error: %s' % err)
else:
raise Exception('That command should have failed')