~abentley/juju-ci-tools/client-from-config-4

« back to all changes in this revision

Viewing changes to tests/test_scale_out.py

  • Committer: Aaron Bentley
  • Date: 2016-03-18 14:47:06 UTC
  • mto: This revision was merged to the branch mainline in revision 1324.
  • Revision ID: aaron.bentley@canonical.com-20160318144706-z7wy9c21m3psi6g5
Introduce set_model_name, update tests, check controller on bootstrap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    def fake_client_cxt(self):
31
31
        env = JujuData('foo', {})
32
32
        client = fake_EnvJujuClient(env)
33
 
        bv_cxt = patch('scale_out.client_from_config',
 
33
        bv_cxt = patch('jujupy.EnvJujuClient.by_version',
34
34
                       return_value=client)
35
 
        with bv_cxt as bv_mock:
36
 
            yield (client, env, bv_mock)
 
35
        fc_cxt = patch('jujupy.SimpleEnvironment.from_config',
 
36
                       return_value=env)
 
37
        with bv_cxt, fc_cxt:
 
38
            yield (client, env)
37
39
 
38
40
    def test_parse_args(self):
39
41
        args = parse_args(
58
60
        self.assertEqual(args, expected)
59
61
 
60
62
    @patch('scale_out.boot_context', autospec=True)
61
 
    @patch('jujupy.EnvJujuClient.add_ssh_machines', autospec=True)
 
63
    @patch('scale_out.EnvJujuClient.add_ssh_machines', autospec=True)
62
64
    def test_scaleout_setup(
63
65
            self,
64
66
            add_ssh_machines_func,
82
84
            verbose=logging.INFO
83
85
        )
84
86
 
85
 
        with self.fake_client_cxt() as (fake_client, fake_env, bv_mock):
 
87
        with self.fake_client_cxt() as (fake_client, fake_env):
86
88
            with scaleout_setup(args) as client:
 
89
                # Get a reference to the by_version function that was patched
 
90
                # in fake_client_cxt()
 
91
                bv_mock = EnvJujuClient.by_version
87
92
                pass
88
93
        boot_context_func.assert_called_once_with(
89
94
            args.temp_env_name,
97
102
            args.keep_env,
98
103
            args.upload_tools,
99
104
            region=args.region)
100
 
        bv_mock.assert_called_once_with('test_env', '/path/juju', False)
 
105
        bv_mock.assert_called_once_with(fake_env, '/path/juju', False)
101
106
        add_ssh_machines_func.assert_called_once_with(client, ['0'])
102
107
        self.assertIs(client, fake_client)
103
108
 
123
128
 
124
129
        with self.fake_client_cxt():
125
130
            with patch('scale_out.boot_context', autospec=True) as bc_mock:
126
 
                with patch('jujupy.EnvJujuClient.add_ssh_machines',
 
131
                with patch('scale_out.EnvJujuClient.add_ssh_machines',
127
132
                           autospec=True):
128
133
                    with scaleout_setup(args) as client:
129
134
                        pass
141
146
            region=args.region)
142
147
 
143
148
    def test_deploy_charms(self):
144
 
        with self.fake_client_cxt() as (client, env, bv_mock):
 
149
        with self.fake_client_cxt() as (client, env):
145
150
            with patch.object(EnvJujuClient, 'deploy') as d_mock:
146
151
                with patch.object(EnvJujuClient,
147
152
                                  'wait_for_started') as wfs_mock:
152
157
        wfs_mock.assert_called_once_with()
153
158
 
154
159
    def test_deploy_charms_local(self):
155
 
        with self.fake_client_cxt() as (client, env, bv_mock):
 
160
        with self.fake_client_cxt() as (client, env):
156
161
            with patch.object(EnvJujuClient, 'deploy') as d_mock:
157
162
                with patch.object(EnvJujuClient,
158
163
                                  'wait_for_started') as wfs_mock:
163
168
        wfs_mock.assert_called_once_with()
164
169
 
165
170
    def test_scale_out(self):
166
 
        with self.fake_client_cxt() as (client, env, bv_mock):
 
171
        with self.fake_client_cxt() as (client, env):
167
172
            with patch.object(EnvJujuClient, 'juju') as j_mock:
168
173
                with patch.object(EnvJujuClient,
169
174
                                  'wait_for_started') as wfs_mock: