LEFT | RIGHT |
1 # This file is part of the Juju Quickstart Plugin, which lets users set up a | 1 # This file is part of the Juju Quickstart Plugin, which lets users set up a |
2 # Juju environment in very few steps (https://launchpad.net/juju-quickstart). | 2 # Juju environment in very few steps (https://launchpad.net/juju-quickstart). |
3 # Copyright (C) 2013-2014 Canonical Ltd. | 3 # Copyright (C) 2013-2014 Canonical Ltd. |
4 # | 4 # |
5 # This program is free software: you can redistribute it and/or modify it under | 5 # This program is free software: you can redistribute it and/or modify it under |
6 # the terms of the GNU Affero General Public License version 3, as published by | 6 # the terms of the GNU Affero General Public License version 3, as published by |
7 # the Free Software Foundation. | 7 # the Free Software Foundation. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 options = self.make_options( | 842 options = self.make_options( |
843 admin_secret=None, | 843 admin_secret=None, |
844 env_name='local', | 844 env_name='local', |
845 env_file='environments.yaml') | 845 env_file='environments.yaml') |
846 with self.assertRaises(app.ProgramExit) as context: | 846 with self.assertRaises(app.ProgramExit) as context: |
847 manage.run(options) | 847 manage.run(options) |
848 expected = ( | 848 expected = ( |
849 u'admin-secret not found in ~/.juju/environments/local.jenv ' | 849 u'admin-secret not found in ~/.juju/environments/local.jenv ' |
850 'or environments.yaml') | 850 'or environments.yaml') |
851 self.assertEqual(expected, context.exception.message) | 851 self.assertEqual(expected, context.exception.message) |
852 | |
853 def test_control_bucket_fetched(self, mock_app, mock_open): | |
854 # If a control bucket is fetched from jenv it is used, even if one is | |
855 # found in environments.yaml, as set in options.control_bucket. | |
856 mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_success | |
857 mock_app.bootstrap.return_value = (True, 'precise') | |
858 options = self.make_options(control_bucket='cb_in_environments.yaml') | |
859 manage.run(options) | |
860 mock_app.connect.assert_has_calls([ | |
861 mock.call(mock_app.get_api_url(), 'from jenv'), | |
862 ]) | |
863 | |
864 def test_control_bucket_from_environments_yaml(self, mock_app, mock_open): | |
865 # If a control bucket is not fetched from jenv, then the one from | |
866 # environments.yaml is used, as found in options.control_bucket. | |
867 mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error | |
868 mock_app.bootstrap.return_value = (True, 'precise') | |
869 options = self.make_options(control_bucket='cb_in_environments.yaml') | |
870 manage.run(options) | |
871 self.assertEqual(options.control_bucket, | |
872 'cb_in_environments.yaml') | |
873 | |
874 def test_no_control_bucket_found(self, mock_app, mock_open): | |
875 # If control-bucket cannot be found anywhere a ProgramExit is called. | |
876 mock_app.ProgramExit = app.ProgramExit | |
877 mock_app.get_value_from_jenv = self.mock_get_value_from_jenv_error | |
878 mock_app.bootstrap.return_value = (True, 'precise') | |
879 options = self.make_options( | |
880 control_bucket=None, | |
881 admin_secret='secret in environments.yaml', | |
882 env_name='local', | |
883 env_file='environments.yaml') | |
884 with self.assertRaises(app.ProgramExit) as context: | |
885 manage.run(options) | |
886 expected = ( | |
887 u'control-bucket not found in ~/.juju/environments/local.jenv ' | |
888 'or environments.yaml') | |
889 self.assertEqual(expected, context.exception.message) | |
LEFT | RIGHT |