3
from unittest import TestCase
9
from build_juju import (
14
from utility import temp_dir
17
class JujuBuildTestCase(TestCase):
19
def test_main_options(self):
20
with patch('build_juju.build_juju', autospec=True) as mock:
21
main(['-d', '-v', '-b', '1234', 'win-client', './foo',
22
'--user', 'jrandom', '--password', 'password1'])
23
args, kwargs = mock.call_args
25
(Credentials('jrandom', 'password1'), 'win-client', './foo',
27
self.assertTrue(kwargs['dry_run'])
28
self.assertTrue(kwargs['verbose'])
30
def test_build_juju(self):
31
credentials = Credentials('jrandom', 'password1')
32
with temp_dir() as base_dir:
33
work_dir = os.path.join(base_dir, 'workspace')
34
with patch('build_juju.setup_workspace', autospec=True) as sw_mock:
36
Artifact('juju-core_1.2.3.tar.gz', 'http:...')]
37
with patch('build_juju.get_artifacts',
38
return_value=artifacts, autospec=True) as ga_mock:
39
with patch('build_juju.run_command') as rc_mock:
40
with patch('build_juju.add_artifacts', autospec=True
43
credentials, 'win-client', work_dir,
44
'lastSucessful', dry_run=True, verbose=True)
45
self.assertEqual((work_dir, ), sw_mock.call_args[0])
47
{'dry_run': True, 'verbose': True}, sw_mock.call_args[1])
49
(credentials, 'build-revision', 'lastSucessful',
50
'juju-core_*.tar.gz', work_dir,),
53
{'archive': False, 'dry_run': True, 'verbose': True},
55
crossbuild = get_script()
57
([crossbuild, 'win-client', '-b', '~/crossbuild',
58
'juju-core_1.2.3.tar.gz'], ),
61
{'dry_run': True, 'verbose': True}, rc_mock.call_args[1])
63
'juju-setup-*.exe', 'juju-*-win2012-amd64.tgz',
64
'juju-*-osx.tar.gz', 'juju-*-centos7-amd64.tgz',
65
'juju-*-centos7.tar.gz']
66
self.assertEqual((work_dir, globs), aa_mock.call_args[0])
68
{'dry_run': True, 'verbose': True}, aa_mock.call_args[1])
70
def test_get_script(self):
72
'/foo/juju-release-tools/crossbuild.py',
73
get_script('/foo/juju-release-tools'))
74
parent_dir = os.path.realpath(
75
os.path.join(__file__, '..', '..', '..'))
77
os.path.join(parent_dir, 'juju-release-tools', 'crossbuild.py'),