def testGetSwarmingTaskDataAndResultIsolatedError(self, mock_fn, _): data = {'outputs_ref': 'ref', 'state': constants.STATE_COMPLETED} mock_fn.return_value = (data, None) self.assertEqual( (data, None, 'error'), swarmed_test_util.GetSwarmingTaskDataAndResult(None, None))
def testGetSwarmingTaskDataAndResultFailedState(self, mock_fn): data = {'state': 'BOT_DIED', 'outputs_ref': 'outputs_ref'} mock_fn.return_value = (data, None) error = SwarmingTaskError.FromSerializable({ 'code': swarming_task_error.BOT_DIED, 'message': 'BOT_DIED' }) self.assertEqual( (data, None, error), swarmed_test_util.GetSwarmingTaskDataAndResult('task_id', None))
def testGetSwarmingTaskDataAndResultNoOutputRef(self, mock_fn): data = {'state': constants.STATE_COMPLETED} mock_fn.return_value = (data, None) error = SwarmingTaskError.FromSerializable({ 'code': swarming_task_error.NO_TASK_OUTPUTS, 'message': 'outputs_ref is None' }) self.assertEqual( (data, None, error), swarmed_test_util.GetSwarmingTaskDataAndResult(None, None))
def testGetSwarmingTaskDataAndResult(self, mock_fn, *_): task_id = '2944afa502297110' data, result, error = swarmed_test_util.GetSwarmingTaskDataAndResult( task_id, None) self.assertEqual( { 'outputs_ref': 'ref', 'state': constants.STATE_COMPLETED }, data) self.assertEqual('content', result) self.assertIsNone(error) mock_fn.assert_called_once_with('chromium-swarm.appspot.com', task_id, None)
def testGetSwarmingTaskDataAndResultRunning(self, mock_fn): data = {'state': constants.STATE_RUNNING, 'outputs_ref': 'outputs_ref'} mock_fn.return_value = (data, None) self.assertEqual( (data, None, None), swarmed_test_util.GetSwarmingTaskDataAndResult('task_id', None))
def testGetSwarmingTaskDataAndResultNoData(self, mock_fn): error = {'code': 1, 'message': 'error'} mock_fn.return_value = (None, error) self.assertEqual( (None, None, SwarmingTaskError.FromSerializable(error)), swarmed_test_util.GetSwarmingTaskDataAndResult('task_id', None))