def test_status_error(self, mock_get): mock_get.return_value = {'error': 'boom'} discoverd._check_status(self.task) mock_get.assert_called_once_with(self.node.uuid, auth_token='the token') self.task.process_event.assert_called_once_with('fail') self.assertIn('boom', self.node.last_error)
def test_service_url(self, mock_get): self.config(service_url='meow', group='discoverd') mock_get.return_value = {'finished': True} discoverd._check_status(self.task) mock_get.assert_called_once_with(self.node.uuid, auth_token='the token', base_url='meow') self.task.process_event.assert_called_once_with('done')
def test_status_ok(self, mock_get): mock_get.return_value = {'finished': True} discoverd._check_status(self.task) mock_get.assert_called_once_with(self.node.uuid, auth_token='the token') self.task.process_event.assert_called_once_with('done')
def test_exception_ignored(self, mock_get): mock_get.side_effect = RuntimeError('boom') discoverd._check_status(self.task) mock_get.assert_called_once_with(self.node.uuid, auth_token='the token') self.assertFalse(self.task.process_event.called)
def test_not_finished(self, mock_get): mock_get.return_value = {} discoverd._check_status(self.task) mock_get.assert_called_once_with(self.node.uuid, auth_token='the token') self.assertFalse(self.task.process_event.called)
def test_not_discoverd(self, mock_get): self.task.driver.inspect = object() discoverd._check_status(self.task) self.assertFalse(mock_get.called)
def test_not_inspecting(self, mock_get): self.node.provision_state = states.MANAGEABLE discoverd._check_status(self.task) self.assertFalse(mock_get.called)