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

« back to all changes in this revision

Viewing changes to tests/test_industrial_test.py

  • Committer: Aaron Bentley
  • Date: 2016-05-23 03:02:18 UTC
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: aaron.bentley@canonical.com-20160523030218-r922ao63nfif6l4d
Rename FakeJujuClient to fake_juju_client.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
from tests.test_deploy_stack import FakeBootstrapManager
69
69
from test_jujupy import (
70
70
    assert_juju_call,
71
 
    FakeJujuClient,
 
71
    fake_juju_client,
72
72
    FakePopen,
73
73
    observable_temp_file,
74
74
    )
639
639
            ]), log_dir, 5, 10)
640
640
 
641
641
        def side_effect(env, full_path=None, debug=False):
642
 
            return FakeJujuClient(None, full_path, debug)
 
642
            return fake_juju_client(None, full_path, debug)
643
643
 
644
644
        with self.patch_client(side_effect):
645
645
            with patch('industrial_test.BootstrapManager',
671
671
            ]), log_dir, 5, 6)
672
672
 
673
673
        def side_effect(env, full_path=None, debug=False):
674
 
            return FakeJujuClient(None, full_path, debug)
 
674
            return fake_juju_client(None, full_path, debug)
675
675
 
676
676
        with self.patch_client(side_effect):
677
677
            with patch('industrial_test.BootstrapManager',
705
705
            log_dir, 5, 4)
706
706
 
707
707
        def side_effect(env, full_path=None, debug=False):
708
 
            return FakeJujuClient(None, full_path, debug)
 
708
            return fake_juju_client(None, full_path, debug)
709
709
 
710
710
        with self.patch_client(side_effect):
711
711
            with patch('industrial_test.BootstrapManager',
877
877
        self.assertEqual(len(cc_mock.mock_calls), 0)
878
878
 
879
879
    def test_run_stages_old_fail(self):
880
 
        old_client = FakeJujuClient()
881
 
        new_client = FakeJujuClient(full_path='bar-path')
 
880
        old_client = fake_juju_client()
 
881
        new_client = fake_juju_client(full_path='bar-path')
882
882
        industrial = IndustrialTest(old_client, new_client, [
883
883
            FakeStepAttempt.from_result(False, True),
884
884
            FakeStepAttempt.from_result(True, True)])
901
901
                         new_client._backend.controller_state.state)
902
902
 
903
903
    def test_run_stages_new_fail(self):
904
 
        old_client = FakeJujuClient()
905
 
        new_client = FakeJujuClient(full_path='bar-path')
 
904
        old_client = fake_juju_client()
 
905
        new_client = fake_juju_client(full_path='bar-path')
906
906
        log_dir = use_context(self, temp_dir())
907
907
        suite_factory = AttemptSuiteFactory([
908
908
            FakeAttemptClass('foo', True, False, new_path='bar-path'),
922
922
                         new_client._backend.controller_state.state)
923
923
 
924
924
    def test_run_stages_both_fail(self):
925
 
        old_client = FakeJujuClient()
926
 
        new_client = FakeJujuClient()
 
925
        old_client = fake_juju_client()
 
926
        new_client = fake_juju_client()
927
927
        log_dir = use_context(self, temp_dir())
928
928
        suite = AttemptSuiteFactory([
929
929
            FakeAttemptClass('foo', False, False),
943
943
                         new_client._backend.controller_state.state)
944
944
 
945
945
    def test_run_stages_recover_failure(self):
946
 
        old_client = FakeJujuClient()
947
 
        new_client = FakeJujuClient()
 
946
        old_client = fake_juju_client()
 
947
        new_client = fake_juju_client()
948
948
        fsa = FakeStepAttempt([('foo', True, False), ('bar', True, True)])
949
949
        industrial = IndustrialTest(old_client, new_client, [
950
950
            fsa, FakeStepAttempt.from_result(True, True)])
970
970
            list(industrial.run_stages())
971
971
 
972
972
    def test_run_attempt(self):
973
 
        old_client = FakeJujuClient()
974
 
        new_client = FakeJujuClient()
 
973
        old_client = fake_juju_client()
 
974
        new_client = fake_juju_client()
975
975
        attempt = FakeStepAttempt.from_result(True, True)
976
976
        log_dir = use_context(self, temp_dir())
977
977
        suite = AttemptSuiteFactory([attempt]).factory([], log_dir, None)
1299
1299
            iterator.next()
1300
1300
 
1301
1301
    def test_iter_steps_kill_controller(self):
1302
 
        client = FakeJujuClient()
 
1302
        client = fake_juju_client()
1303
1303
        client.bootstrap()
1304
1304
        destroy_env = DestroyEnvironmentAttempt()
1305
1305
        iterator = iter_steps_validate_info(self, destroy_env, client)
1729
1729
 
1730
1730
    def get_wait_until_removed_timeout(self, container_type):
1731
1731
        deploy_many = DeployManyAttempt()
1732
 
        client = FakeJujuClient()
 
1732
        client = fake_juju_client()
1733
1733
        client.bootstrap()
1734
1734
        deploy_iter = iter_steps_validate_info(self, deploy_many, client)
1735
1735
        with patch('industrial_test.wait_until_removed') as wur_mock:
1835
1835
            PrepareUpgradeJujuAttempt.factory([], None)
1836
1836
 
1837
1837
    def test_get_bootstrap_client(self):
1838
 
        client = FakeJujuClient(full_path='c', debug=True)
 
1838
        client = fake_juju_client(full_path='c', debug=True)
1839
1839
        puj_attempt = PrepareUpgradeJujuAttempt.factory(['a', 'b', 'c'], None)
1840
1840
 
1841
1841
        def by_version(env, path, debug):
1842
 
            return FakeJujuClient(env, path, debug)
 
1842
            return fake_juju_client(env, path, debug)
1843
1843
 
1844
1844
        with patch.object(client, 'by_version', by_version):
1845
1845
            bootstrap_client = puj_attempt.get_bootstrap_client(client)
2159
2159
        factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap)
2160
2160
        attempt_suite = AttemptSuite(factory, None, 'asdf', None)
2161
2161
        with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm):
2162
 
            client = FakeJujuClient()
 
2162
            client = fake_juju_client()
2163
2163
            attempt_suite.iter_steps(client)
2164
2164
        mock_bm.assert_called_once_with(
2165
2165
            'name', client, client, agent_stream=None, agent_url=None,
2172
2172
        factory = AttemptSuiteFactory([], bootstrap_attempt=fake_bootstrap)
2173
2173
        attempt_suite = AttemptSuite(factory, None, 'asdf', 'bar-stream')
2174
2174
        with self.iter_steps_cxt(attempt_suite) as (mock_ibms, mock_bm):
2175
 
            client = FakeJujuClient()
 
2175
            client = fake_juju_client()
2176
2176
            iterator = attempt_suite.iter_steps(client)
2177
2177
        self.assertEqual(iterator, mock_ibms.return_value)
2178
2178
        mock_bm.assert_called_once_with(
2188
2188
        factory = AttemptSuiteFactory([fake_1, fake_2],
2189
2189
                                      bootstrap_attempt=fake_bootstrap)
2190
2190
        attempt_suite = AttemptSuite(factory, None, None, None)
2191
 
        client = FakeJujuClient()
 
2191
        client = fake_juju_client()
2192
2192
        bs_manager = FakeBootstrapManager(client)
2193
2193
        steps = list(attempt_suite._iter_bs_manager_steps(
2194
2194
            bs_manager, client, fake_bootstrap(), True))
2213
2213
        factory = AttemptSuiteFactory([fake_1],
2214
2214
                                      bootstrap_attempt=fake_bootstrap)
2215
2215
        attempt_suite = AttemptSuite(factory, None, None, None)
2216
 
        client = FakeJujuClient()
 
2216
        client = fake_juju_client()
2217
2217
        bs_manager = FakeBootstrapManager(client, keep_env=True)
2218
2218
        with self.assertRaisesRegexp(Exception, 'fake exception'):
2219
2219
            list(attempt_suite._iter_bs_manager_steps(