~juju-qa/juju-ci-tools/trunk

« back to all changes in this revision

Viewing changes to tests/test_jujupy.py

  • Committer: Christopher Lee
  • Date: 2016-10-26 04:59:52 UTC
  • mfrom: (1689 trunk)
  • mto: This revision was merged to the branch mainline in revision 1698.
  • Revision ID: chris.lee@canonical.com-20161026045952-g0l8ba05nmo5a638
Merge trunk. Fix conflict issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1045
1045
            'destroy-model', ('foo', '-y'),
1046
1046
            include_e=False, timeout=1800)
1047
1047
 
1048
 
    def test_kill_controller_system(self):
1049
 
        self.do_kill_controller('system', 'system kill')
1050
 
 
1051
 
    def test_kill_controller_controller(self):
1052
 
        self.do_kill_controller('controller', 'controller kill')
1053
 
 
1054
 
    def test_kill_controller_hyphenated(self):
1055
 
        self.do_kill_controller('kill-controller', 'kill-controller')
1056
 
 
1057
 
    def do_kill_controller(self, jes_command, kill_command):
 
1048
    def test_kill_controller(self):
1058
1049
        client = EnvJujuClient(JujuData('foo', {'type': 'gce'}), None, None)
1059
 
        with patch.object(client, 'get_jes_command',
1060
 
                          return_value=jes_command):
1061
 
            with patch.object(client, 'juju') as juju_mock:
1062
 
                client.kill_controller()
 
1050
        with patch.object(client, 'juju') as juju_mock:
 
1051
            client.kill_controller()
1063
1052
        juju_mock.assert_called_once_with(
1064
 
            kill_command, ('foo', '-y'), check=False, include_e=False,
 
1053
            'kill-controller', ('foo', '-y'), check=False, include_e=False,
1065
1054
            timeout=600)
1066
1055
 
1067
1056
    def do_kill_controller_azure(self, jes_command, kill_command):
1074
1063
            kill_command, ('foo', '-y'), check=False, include_e=False,
1075
1064
            timeout=1800)
1076
1065
 
 
1066
    def test_destroy_controller(self):
 
1067
        client = EnvJujuClient(JujuData('foo', {'type': 'gce'}), None, None)
 
1068
        with patch.object(client, 'juju') as juju_mock:
 
1069
            client.destroy_controller()
 
1070
        juju_mock.assert_called_once_with(
 
1071
            'destroy-controller', ('foo', '-y'), include_e=False,
 
1072
            timeout=600)
 
1073
 
1077
1074
    def test_get_juju_output(self):
1078
1075
        env = JujuData('foo')
1079
1076
        client = EnvJujuClient(env, None, 'juju')
3512
3509
                client.destroy_environment()
3513
3510
            mock.assert_called_with(
3514
3511
                'destroy-environment', ('foo', '--force', '-y'),
3515
 
                False, check=False, include_e=False, timeout=600)
 
3512
                check=False, include_e=False, timeout=600)
3516
3513
 
3517
3514
    def test_destroy_environment_sudo(self):
3518
3515
        env = SimpleEnvironment('foo', {'type': 'gce'})
3522
3519
                client.destroy_environment()
3523
3520
            mock.assert_called_with(
3524
3521
                'destroy-environment', ('foo', '--force', '-y'),
3525
 
                True, check=False, include_e=False, timeout=600)
 
3522
                check=False, include_e=False, timeout=600)
3526
3523
 
3527
3524
    def test_destroy_environment_no_force(self):
3528
3525
        env = SimpleEnvironment('foo', {'type': 'gce'})
3531
3528
            client.destroy_environment(force=False)
3532
3529
            mock.assert_called_with(
3533
3530
                'destroy-environment', ('foo', '-y'),
3534
 
                False, check=False, include_e=False, timeout=600)
 
3531
                check=False, include_e=False, timeout=600)
3535
3532
 
3536
3533
    def test_destroy_environment_azure(self):
3537
3534
        env = SimpleEnvironment('foo', {'type': 'azure'})
3540
3537
            client.destroy_environment(force=False)
3541
3538
            mock.assert_called_with(
3542
3539
                'destroy-environment', ('foo', '-y'),
3543
 
                False, check=False, include_e=False, timeout=1800)
 
3540
                check=False, include_e=False, timeout=1800)
3544
3541
 
3545
3542
    def test_destroy_environment_delete_jenv(self):
3546
3543
        env = SimpleEnvironment('foo', {'type': 'gce'})
3562
3559
            client.destroy_model()
3563
3560
        mock.assert_called_with(
3564
3561
            'destroy-environment', ('foo', '-y'),
3565
 
            False, check=False, include_e=False, timeout=600)
3566
 
 
3567
 
    def test_kill_controller_system(self):
3568
 
        self.do_kill_controller('system', 'system kill')
3569
 
 
3570
 
    def test_kill_controller_controller(self):
3571
 
        self.do_kill_controller('controller', 'controller kill')
3572
 
 
3573
 
    def test_kill_controller_hyphenated(self):
3574
 
        self.do_kill_controller('kill-controller', 'kill-controller')
3575
 
 
3576
 
    def do_kill_controller(self, jes_command, kill_command):
3577
 
        client = EnvJujuClient1X(
3578
 
            SimpleEnvironment('foo', {'type': 'gce'}), None, None)
3579
 
        with patch.object(client, 'get_jes_command',
3580
 
                          return_value=jes_command):
3581
 
            with patch.object(client, 'juju') as juju_mock:
3582
 
                client.kill_controller()
3583
 
        juju_mock.assert_called_once_with(
3584
 
            kill_command, ('foo', '-y'), check=False, include_e=False,
3585
 
            timeout=600)
 
3562
            check=False, include_e=False, timeout=600)
 
3563
 
 
3564
    def test_kill_controller(self):
 
3565
        client = EnvJujuClient1X(
 
3566
            SimpleEnvironment('foo', {'type': 'gce'}), None, None)
 
3567
        with patch.object(client, 'juju') as juju_mock:
 
3568
            client.kill_controller()
 
3569
        juju_mock.assert_called_once_with(
 
3570
            'destroy-environment', ('foo', '--force', '-y'), check=False,
 
3571
            include_e=False, timeout=600)
 
3572
 
 
3573
    def test_destroy_controller(self):
 
3574
        client = EnvJujuClient1X(
 
3575
            SimpleEnvironment('foo', {'type': 'gce'}), None, None)
 
3576
        with patch.object(client, 'juju') as juju_mock:
 
3577
            client.destroy_controller()
 
3578
        juju_mock.assert_called_once_with(
 
3579
            'destroy-environment', ('foo', '-y'),
 
3580
            include_e=False, timeout=600)
3586
3581
 
3587
3582
    def test_get_juju_output(self):
3588
3583
        env = SimpleEnvironment('foo')