~frankban/juju-quickstart/env-creation-proto2

« back to all changes in this revision

Viewing changes to quickstart/tests/test_manage.py

  • Committer: Francesco Banconi
  • Date: 2013-11-20 14:51:14 UTC
  • mfrom: (17.1.5 local-provider)
  • Revision ID: francesco.banconi@canonical.com-20131120145114-hghyg5b8ca0kq8ed
Add support for local providers.

Bootstrap the environment with "sudo" if
the environment is configured to use the 
local provider.

Also improved debugging documentation.

Tests: make check

To QA this, just run `.venv/bin/python juju-quickstart` 
as you are used to, but with the local provider: 
try to deploy a bundle, try to re-run quickstart again 
with the environment already bootstrapped. 
In general the application should ask for sudo password 
and then proceed as usual.

R=rharding
CC=
https://codereview.appspot.com/29540044

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
        env_file = self.make_env_file(contents)
239
239
        options = self.make_options(env_file, env_name='lxc')
240
240
        manage._validate_env(options, self.parser)
241
 
        expected = 'the local provider is not currently supported'
242
 
        self.parser.error.assert_called_once_with(expected)
 
241
        self.assertEqual('Secret!', options.admin_secret)
 
242
        self.assertEqual(env_file, options.env_file)
 
243
        self.assertEqual('lxc', options.env_name)
 
244
        self.assertEqual('local', options.env_type)
243
245
 
244
246
 
245
247
@mock.patch('quickstart.manage._validate_env', mock.Mock())
352
354
        options = self.make_options()
353
355
        manage.run(options)
354
356
        mock_app.bootstrap.assert_called_once_with(
355
 
            options.env_name, debug=options.debug)
 
357
            options.env_name, is_local=False, debug=options.debug)
356
358
        mock_app.get_api_url.assert_called_once_with(options.env_name)
357
359
        mock_app.connect.assert_called_once_with(
358
360
            mock_app.get_api_url(), options.admin_secret)
377
379
            'wss://gui.example.com:443/ws', options.admin_secret,
378
380
            'mybundle: contents', 'mybundle', None)
379
381
 
 
382
    def test_local_provider(self, mock_app, mock_open):
 
383
        # The application correctly handles working with local providers.
 
384
        options = self.make_options(env_type='local')
 
385
        manage.run(options)
 
386
        mock_app.bootstrap.assert_called_once_with(
 
387
            options.env_name, is_local=True, debug=options.debug)
 
388
 
380
389
    def test_no_browser(self, mock_app, mock_open):
381
390
        # It is possible to avoid opening the GUI in the browser.
382
391
        options = self.make_options(open_browser=False)