예제 #1
0
 def test_delete_old_machines(self):
     machine = make_machine('stopped')
     client = Client('sdc_url',
                     'account',
                     'key_id',
                     './key',
                     'manta_url',
                     pause=0)
     with patch.object(client,
                       '_list_machines',
                       side_effect=fake_list_machines(machine)) as lm_mock:
         with patch.object(client,
                           '_list_machine_tags',
                           autospec=True,
                           return_value={}) as lmt_mock:
             with patch.object(client,
                               '_delete_running_machine',
                               autospec=True) as drm_mock:
                 with patch.object(client,
                                   'attempt_deletion',
                                   autospec=True) as rd_mock:
                     client.delete_old_machines(1)
     lm_mock.assert_called_once_with()
     lmt_mock.assert_called_once_with('id')
     drm_mock.assert_called_once_with('id')
     self.assertEqual(0, rd_mock.call_count)
예제 #2
0
 def test_delete_old_machines_stuck_provisioning(self):
     machine = make_machine('provisioning')
     client = Client(
         'sdc_url', 'account', 'key_id', 'manta_url', './key', pause=0)
     with patch.object(client, '_list_machines', autospec=True,
                       side_effect=fake_list_machines(machine)):
         with patch.object(client, '_list_machine_tags', autospec=True):
             with patch.object(client, '_delete_running_machine',
                               autospec=True) as drm_mock:
                 with patch.object(client, 'request_deletion',
                                   autospec=True) as rd_mock:
                     client.delete_old_machines(1, 'foo@bar')
     self.assertEqual(0, drm_mock.call_count)
     rd_mock.assert_called_once_with([machine], 'foo@bar')
예제 #3
0
파일: test_joyent.py 프로젝트: mjs/juju
 def test_delete_old_machines_permanent(self):
     machine = make_machine('provisioning')
     client = Client(
         'sdc_url', 'account', 'key_id', './key', 'manta_url', pause=0)
     with patch.object(client, '_list_machines', autospec=True,
                       side_effect=fake_list_machines(machine)):
         with patch.object(client, '_list_machine_tags', autospec=True,
                           return_value={'permanent': 'true'}) as lmt_mock:
             with patch.object(client, '_delete_running_machine',
                               autospec=True) as drm_mock:
                 with patch.object(client, 'attempt_deletion',
                                   autospec=True) as rd_mock:
                     client.delete_old_machines(1)
     lmt_mock.assert_called_once_with('id')
     self.assertEqual(0, drm_mock.call_count)
     self.assertEqual(0, rd_mock.call_count)
예제 #4
0
파일: test_joyent.py 프로젝트: mjs/juju
 def test_delete_old_machines(self):
     machine = make_machine('stopped')
     client = Client(
         'sdc_url', 'account', 'key_id', './key', 'manta_url', pause=0)
     with patch.object(client, '_list_machines',
                       side_effect=[[machine], [machine]]) as lm_mock:
         with patch.object(client, '_list_machine_tags', autospec=True,
                           return_value={}) as lmt_mock:
             with patch.object(client, '_delete_running_machine',
                               autospec=True) as drm_mock:
                 with patch.object(client, 'request_deletion',
                                   autospec=True) as rd_mock:
                     client.delete_old_machines(1, 'foo@bar')
     lm_mock.assert_called_once_with()
     lmt_mock.assert_called_once_with('id')
     drm_mock.assert_called_once_with('id')
     self.assertEqual(0, rd_mock.call_count)