Index: quickstart/tests/test_manage.py |
=== modified file 'quickstart/tests/test_manage.py' |
--- quickstart/tests/test_manage.py 2014-04-22 12:20:10 +0000 |
+++ quickstart/tests/test_manage.py 2014-04-23 13:08:12 +0000 |
@@ -719,9 +719,19 @@ |
def test_no_bundle(self, mock_app, mock_open): |
# The application runs correctly if no bundle is provided. |
mock_app.ensure_dependencies.return_value = (1, 18, 0) |
- mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
+ mock_app.bootstrap.return_value = (True, 'trusty') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ service_data = {'Name': 'juju-gui'} |
+ unit_data = {'Name': 'juju-gui/0'} |
+ mock_app.check_environment.return_value = ( |
+ 'cs:trusty/juju-gui-42', '0', service_data, unit_data) |
mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error |
+ # Make mock_app.watch return the Juju GUI unit address. |
mock_app.watch.return_value = '1.2.3.4' |
+ # Make mock_app.create_auth_token return a fake authentication token. |
mock_app.create_auth_token.return_value = 'AUTHTOKEN' |
options = self.make_options() |
manage.run(options) |
@@ -736,10 +746,13 @@ |
mock.call('wss://1.2.3.4:443/ws', options.admin_secret), |
mock.call().close(), |
]) |
+ mock_app.check_environment.assert_called_once_with( |
+ mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, |
+ options.charm_url, options.env_type, mock_app.bootstrap()[1], |
+ mock_app.bootstrap()[0]) |
mock_app.deploy_gui.assert_called_once_with( |
- mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, '0', |
- charm_url=options.charm_url, |
- check_preexisting=mock_app.bootstrap()[0]) |
+ mock_app.connect(), settings.JUJU_GUI_SERVICE_NAME, |
+ 'cs:trusty/juju-gui-42', '0', service_data, unit_data) |
mock_app.watch.assert_called_once_with( |
mock_app.connect(), mock_app.deploy_gui()) |
mock_app.create_auth_token.assert_called_once_with(mock_app.connect()) |
@@ -748,8 +761,16 @@ |
self.assertFalse(mock_app.deploy_bundle.called) |
def test_no_token(self, mock_app, mock_open): |
+ # The process continues even if the authentication token cannot be |
+ # retrieved. |
mock_app.create_auth_token.return_value = None |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
options = self.make_options() |
manage.run(options) |
mock_app.create_auth_token.assert_called_once_with(mock_app.connect()) |
@@ -761,7 +782,14 @@ |
options = self.make_options( |
bundle='/my/bundle/file.yaml', bundle_yaml='mybundle: contents', |
bundle_name='mybundle', bundle_services=['service1', 'service2']) |
- mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
+ mock_app.bootstrap.return_value = (True, 'trusty') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:trusty/juju-gui-42', '0', None, None) |
+ # Make mock_app.watch return the Juju GUI unit address. |
mock_app.watch.return_value = 'gui.example.com' |
manage.run(options) |
mock_app.deploy_bundle.assert_called_once_with( |
@@ -774,7 +802,13 @@ |
options = self.make_options(env_type='local') |
versions = [ |
(1, 17, 2), (1, 17, 10), (1, 18, 0), (1, 18, 2), (2, 16, 1)] |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
for version in versions: |
mock_app.ensure_dependencies.return_value = version |
manage.run(options) |
@@ -788,7 +822,13 @@ |
# Sudo privileges are required if the Juju version is < 1.17.2. |
options = self.make_options(env_type='local') |
versions = [(0, 7, 9), (1, 0, 0), (1, 16, 42), (1, 17, 0), (1, 17, 1)] |
- mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
+ mock_app.bootstrap.return_value = (True, 'trusty') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:trusty/juju-gui-42', '0', None, None) |
for version in versions: |
mock_app.ensure_dependencies.return_value = version |
manage.run(options) |
@@ -800,14 +840,26 @@ |
# Sudo privileges are never required for non-local environments. |
options = self.make_options(env_type='ec2') |
mock_app.ensure_dependencies.return_value = (1, 14, 0) |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
manage.run(options) |
mock_app.bootstrap.assert_called_once_with( |
options.env_name, requires_sudo=False, debug=options.debug) |
def test_no_browser(self, mock_app, mock_open): |
# It is possible to avoid opening the GUI in the browser. |
- mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
+ mock_app.bootstrap.return_value = (True, 'trusty') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:trusty/juju-gui-42', '0', None, None) |
options = self.make_options(open_browser=False) |
manage.run(options) |
self.assertFalse(mock_open.called) |
@@ -816,7 +868,13 @@ |
# If an admin secret is fetched from jenv it is used, even if one is |
# found in environments.yaml, as set in options.admin_secret. |
mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_success |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
options = self.make_options(admin_secret='secret in environments.yaml') |
manage.run(options) |
mock_app.connect.assert_has_calls([ |
@@ -827,7 +885,13 @@ |
# If an admin secret is not fetched from jenv, then the one from |
# environments.yaml is used, as found in options.admin_secret. |
mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
options = self.make_options(admin_secret='secret in environments.yaml') |
manage.run(options) |
mock_app.connect.assert_has_calls([ |
@@ -838,7 +902,13 @@ |
# If admin-secret cannot be found anywhere a ProgramExit is called. |
mock_app.ProgramExit = app.ProgramExit |
mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error |
+ # Make mock_app.bootstrap return the already_bootstrapped flag and the |
+ # bootstrap node series. |
mock_app.bootstrap.return_value = (True, 'precise') |
+ # Make mock_app.check_environment return the charm URL, the machine |
+ # where to deploy the charm, the service and unit data. |
+ mock_app.check_environment.return_value = ( |
+ 'cs:precise/juju-gui-42', '0', None, None) |
options = self.make_options( |
admin_secret=None, |
env_name='local', |