~juju-qa/juju-ci-tools/trunk

« back to all changes in this revision

Viewing changes to tests/test_assess_bootstrap.py

  • Committer: Curtis Hovey
  • Date: 2017-01-25 02:32:29 UTC
  • mfrom: (1855 trunk)
  • mto: This revision was merged to the branch mainline in revision 1865.
  • Revision ID: curtis@canonical.com-20170125023229-g7c6bzt0cqe1j8g3
Merged trunk and resolved conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from deploy_stack import (
22
22
    BootstrapManager,
23
23
    )
24
 
from fakejuju import (
 
24
from jujupy import (
25
25
    fake_juju_client,
26
 
    )
27
 
from jujupy import (
28
26
    _temp_env as temp_env,
29
27
    Status,
30
28
    )
160
158
        juju_version = '1.25.5'
161
159
    call_cxt = patch('subprocess.call')
162
160
    cc_cxt = patch('subprocess.check_call')
163
 
    gv_cxt = patch('jujupy.EnvJujuClient.get_version',
 
161
    gv_cxt = patch('jujupy.ModelClient.get_version',
164
162
                   side_effect=lambda cls: juju_version)
165
 
    gjo_cxt = patch('jujupy.EnvJujuClient.get_juju_output', autospec=True,
 
163
    gjo_cxt = patch('jujupy.ModelClient.get_juju_output', autospec=True,
166
164
                    return_value='')
167
 
    imc_cxt = patch('jujupy.EnvJujuClient.iter_model_clients',
 
165
    imc_cxt = patch('jujupy.ModelClient.iter_model_clients',
168
166
                    autospec=True, return_value=[])
169
167
    env_cxt = temp_env({'environments': {'bar': {'type': 'foo'}}})
170
168
    with call_cxt, cc_cxt, gv_cxt, gjo_cxt, env_cxt, imc_cxt:
233
231
            self.assertEqual(myself.env.config,
234
232
                             {'name': 'bar', 'type': 'foo'})
235
233
        with extended_bootstrap_cxt():
236
 
            with patch('jujupy.EnvJujuClient.bootstrap', side_effect=check,
 
234
            with patch('jujupy.ModelClient.bootstrap', side_effect=check,
237
235
                       autospec=True):
238
236
                assess_bootstrap(parse_args(['base', 'bar', '/foo']))
239
237
        self.assertRegexpMatches(
247
245
                    'name': 'qux', 'type': 'foo', 'region': 'baz'})
248
246
            self.assertEqual(myself.env.environment, 'qux')
249
247
        with extended_bootstrap_cxt():
250
 
            with patch('jujupy.EnvJujuClient.bootstrap', side_effect=check,
 
248
            with patch('jujupy.ModelClient.bootstrap', side_effect=check,
251
249
                       autospec=True):
252
250
                args = parse_args(['base', 'bar', '/foo'])
253
251
                args.region = 'baz'
273
271
            self.assertEqual(self.target_dict, myself.env._config)
274
272
            self.assertIsNotNone(metadata_source)
275
273
        with extended_bootstrap_cxt('2.0.0'):
276
 
            with patch('jujupy.EnvJujuClient.bootstrap', side_effect=check,
 
274
            with patch('jujupy.ModelClient.bootstrap', side_effect=check,
277
275
                       autospec=True):
278
276
                args = parse_args(['metadata', 'bar', '/foo'])
279
277
                args.temp_env_name = 'qux'
288
286
            self.assertEqual(self.target_dict, myself.env._config)
289
287
            self.assertEqual('agents', metadata_source)
290
288
        with extended_bootstrap_cxt('2.0.0'):
291
 
            with patch('jujupy.EnvJujuClient.bootstrap', side_effect=check,
 
289
            with patch('jujupy.ModelClient.bootstrap', side_effect=check,
292
290
                       autospec=True):
293
291
                args = parse_args(['metadata', 'bar', '/foo'])
294
292
                args.temp_env_name = 'qux'
300
298
 
301
299
    def test_assess_metadata_valid_url(self):
302
300
        with extended_bootstrap_cxt('2.0.0'):
303
 
            with patch('jujupy.EnvJujuClient.bootstrap', autospec=True):
 
301
            with patch('jujupy.ModelClient.bootstrap', autospec=True):
304
302
                args = parse_args(['metadata', 'bar', '/foo'])
305
303
                args.temp_env_name = 'qux'
306
304
                bs_manager = BootstrapManager.from_args(args)
317
315
    def test_get_controller_address(self):
318
316
        status = Status({'machines': {"0": {'dns-name': '255.1.1.0'}}}, '')
319
317
        client = fake_juju_client()
320
 
        with patch('jujupy.EnvJujuClient.status_until', return_value=[status],
 
318
        with patch('jujupy.ModelClient.status_until', return_value=[status],
321
319
                   autospec=True):
322
320
            self.assertEqual('255.1.1.0', get_controller_address(client))
323
321
 
341
339
                             myself.env._config)
342
340
            self.assertEqual(DEST, to)
343
341
        with extended_bootstrap_cxt('2.0.0'):
344
 
            with patch('jujupy.EnvJujuClient.bootstrap', side_effect=check,
 
342
            with patch('jujupy.ModelClient.bootstrap', side_effect=check,
345
343
                       autospec=True):
346
344
                with patch('assess_bootstrap.get_controller_hostname',
347
345
                           return_value=DEST, autospec=True):
357
355
 
358
356
    def test_assess_to_fails(self):
359
357
        with extended_bootstrap_cxt('2.0.0'):
360
 
            with patch('jujupy.EnvJujuClient.bootstrap', autospec=True):
 
358
            with patch('jujupy.ModelClient.bootstrap', autospec=True):
361
359
                with patch('assess_bootstrap.get_controller_address',
362
360
                           return_value='255.1.1.0', autospec=True):
363
361
                    args = parse_args(['to', 'bar', '/foo',