870.1.2
by Aaron Bentley
Use authenticated access for schedule_hetero_control. |
1 |
from __future__ import print_function |
2 |
||
3 |
__metaclass__ = type |
|
4 |
||
5 |
from unittest import TestCase |
|
6 |
||
7 |
from mock import patch |
|
8 |
||
9 |
from jujuci import Credentials |
|
10 |
from schedule_hetero_control import ( |
|
11 |
build_jobs, |
|
12 |
get_args, |
|
13 |
)
|
|
14 |
from utility import temp_dir |
|
15 |
from test_utility import write_config |
|
16 |
||
17 |
||
18 |
class TestGetArgs(TestCase): |
|
19 |
||
20 |
def test_get_args_credentials(self): |
|
21 |
args, credentials = get_args(['root', '--user', 'jrandom', |
|
22 |
'--password', 'password']) |
|
23 |
self.assertEqual(args.user, 'jrandom') |
|
24 |
self.assertEqual(args.password, 'password') |
|
25 |
self.assertEqual(credentials, Credentials('jrandom', 'password')) |
|
26 |
||
27 |
||
28 |
class TestBuildJobs(TestCase): |
|
29 |
||
30 |
def test_build_jobs_credentials(self): |
|
31 |
credentials = Credentials('jrandom', 'password1') |
|
32 |
with temp_dir() as root: |
|
33 |
write_config(root, 'compatibility-control', 'asdf') |
|
34 |
with patch('schedule_hetero_control.Jenkins', |
|
35 |
autospec=True) as jenkins_mock: |
|
36 |
build_jobs(credentials, root, []) |
|
37 |
jenkins_mock.assert_called_once_with( |
|
38 |
'http://localhost:8080', 'jrandom', 'password1') |