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

« back to all changes in this revision

Viewing changes to tests/test_joyent.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                              return_value={}) as lmt_mock:
80
80
                with patch.object(client, '_delete_running_machine',
81
81
                                  autospec=True) as drm_mock:
82
 
                    with patch.object(client, 'attempt_deletion',
 
82
                    with patch.object(client, 'request_deletion',
83
83
                                      autospec=True) as rd_mock:
84
 
                        client.delete_old_machines(1)
 
84
                        client.delete_old_machines(1, 'foo@bar')
85
85
        lm_mock.assert_called_once_with()
86
86
        lmt_mock.assert_called_once_with('id')
87
87
        drm_mock.assert_called_once_with('id')
96
96
            with patch.object(client, '_list_machine_tags', autospec=True):
97
97
                with patch.object(client, '_delete_running_machine',
98
98
                                  autospec=True) as drm_mock:
99
 
                    with patch.object(client, 'attempt_deletion',
 
99
                    with patch.object(client, 'request_deletion',
100
100
                                      autospec=True) as rd_mock:
101
 
                        client.delete_old_machines(1)
 
101
                        client.delete_old_machines(1, 'foo@bar')
102
102
        self.assertEqual(0, drm_mock.call_count)
103
 
        rd_mock.assert_called_once_with([machine])
 
103
        rd_mock.assert_called_once_with([machine], 'foo@bar')
104
104
 
105
105
    def test_delete_old_machines_permanent(self):
106
106
        machine = make_machine('provisioning')
112
112
                              return_value={'permanent': 'true'}) as lmt_mock:
113
113
                with patch.object(client, '_delete_running_machine',
114
114
                                  autospec=True) as drm_mock:
115
 
                    with patch.object(client, 'attempt_deletion',
 
115
                    with patch.object(client, 'request_deletion',
116
116
                                      autospec=True) as rd_mock:
117
 
                        client.delete_old_machines(1)
 
117
                        client.delete_old_machines(1, 'foo@bar')
118
118
        lmt_mock.assert_called_once_with('id')
119
119
        self.assertEqual(0, drm_mock.call_count)
120
120
        self.assertEqual(0, rd_mock.call_count)
121
 
 
122
 
    def test_attempt_deletion(self):
123
 
        client = Client(
124
 
            'sdc_url', 'account', 'key_id', './key', 'manta_url', pause=0)
125
 
        with patch.object(client, 'delete_machine', autospec=True) as dm_func:
126
 
            all_success = client.attempt_deletion(['a', 'b'])
127
 
        self.assertIs(True, all_success)
128
 
        dm_func.assert_any_call('a')
129
 
        dm_func.assert_any_call('b')
130
 
        with patch.object(client, 'delete_machine', autospec=True,
131
 
                          side_effect=[Exception, None]) as dm_func:
132
 
            all_success = client.attempt_deletion(['a', 'b'])
133
 
        self.assertIs(False, all_success)
134
 
        dm_func.assert_any_call('a')
135
 
        dm_func.assert_any_call('b')