~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to tests/test_quickstart_deploy.py

  • Committer: Curtis Hovey
  • Date: 2016-09-21 17:54:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1612.
  • Revision ID: curtis@canonical.com-20160921175426-hmk3wlxrl1vpfuwr
Poll for the token, whcih might be None.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
)
6
6
 
7
7
from deploy_stack import BootstrapManager
 
8
from fakejuju import fake_juju_client
8
9
from jujupy import (
9
10
    EnvJujuClient,
10
11
    JujuData,
15
16
    use_context,
16
17
)
17
18
from tests.test_deploy_stack import FakeBootstrapManager
18
 
from tests.test_jujupy import FakeJujuClient
19
19
from utility import temp_dir
20
20
 
21
21
 
85
85
        with patch('deploy_stack.get_machine_dns_name',
86
86
                   return_value='mocked_name') as dns_mock:
87
87
            # Test second yield
88
 
            with patch.object(client, 'get_admin_client') as gac_mock:
 
88
            with patch.object(client, 'get_controller_client') as gcc_mock:
89
89
                step = steps.next()
90
 
        dns_mock.assert_called_once_with(gac_mock.return_value, '0')
 
90
        dns_mock.assert_called_once_with(gcc_mock.return_value, '0')
91
91
        self.assertEqual('mocked_name', step['bootstrap_host'])
92
92
        with patch.object(client, 'wait_for_deploy_started') as wds_mock:
93
93
            # Test third yield
102
102
        with patch('deploy_stack.safe_print_status'):
103
103
            with patch('deploy_stack.tear_down'):
104
104
                with patch('quickstart_deploy.BootstrapManager.dump_all_logs'):
105
 
                    steps.close()
 
105
                    with patch('jujupy.EnvJujuClient.iter_model_clients',
 
106
                               return_value=[]):
 
107
                        steps.close()
106
108
 
107
109
    def test_iter_steps_context(self):
108
 
        client = FakeJujuClient()
 
110
        client = fake_juju_client()
109
111
        bs_manager = FakeBootstrapManager(client)
110
112
        quickstart = QuickstartTest(bs_manager, '/tmp/bundle.yaml', 2)
111
113
        step_iter = quickstart.iter_steps()
114
116
        self.assertIs(False, bs_manager.entered_bootstrap)
115
117
        self.assertIs(False, bs_manager.exited_bootstrap)
116
118
        step_iter.next()
117
 
        backing_state = client._backing_state
 
119
        models = client._backend.controller_state.models
 
120
        backing_state = models[client.model_name]
118
121
        self.assertEqual('/tmp/bundle.yaml', backing_state.current_bundle)
119
122
        self.assertIs(True, bs_manager.entered_top)
120
123
        self.assertIs(True, bs_manager.entered_bootstrap)
152
155
        self.assertIs(True, bs_manager.exited_top)
153
156
 
154
157
    def test_iter_steps_wait_fail(self):
155
 
        client = FakeJujuClient()
 
158
        client = fake_juju_client()
156
159
        bs_manager = FakeBootstrapManager(client)
157
160
        quickstart = QuickstartTest(bs_manager, '/tmp/bundle.yaml', 2)
158
161
        step_iter = quickstart.iter_steps()