Beispiel #1
0
def test_task_serializer(mock_seralization):
    """
    Test task_serializer helper function.
    """
    mock_seralization.dispatch.task_status.return_value = {'status': 'mock'}
    mock_seralization.dispatch.spawned_tasks.return_value = {
        'spawned_task': 'mock'
    }
    mock_seralization.dispatch.task_result_href.return_value = {
        '_href': '/mock/path/'
    }

    task = {'id': 'mock_task'}
    serialized_task = task_serializer(task)
    mock_seralization.dispatch.task_status.assert_called_once()
    mock_seralization.dispatch.spawned_tasks.assert_called_once()
    mock_seralization.dispatch.task_result_href.assert_called_once()

    expected_task = {
        'status': 'mock',
        'spawned_task': 'mock',
        '_href': '/mock/path/'
    }
    if serialized_task != expected_task:
        raise AssertionError(
            "Task serializer did not generate expected task. \n" +
            "Task: {}, \nExpected Task: {}".format(serialized_task,
                                                   expected_task))
Beispiel #2
0
 def data(self):
     """
     Generate a data report for this event.
     @return: dictionary of this event's fields
     @rtype: dict
     """
     d = {'event_type': self.event_type,
          'payload': self.payload,
          'call_report': task_serializer(self.call_report)}
     return d
Beispiel #3
0
 def data(self):
     """
     Generate a data report for this event.
     @return: dictionary of this event's fields
     @rtype: dict
     """
     d = {
         'event_type': self.event_type,
         'payload': self.payload,
         'call_report': task_serializer(self.call_report)
     }
     return d
Beispiel #4
0
def test_task_serializer(mock_seralization):
    """
    Test task_serializer helper function.
    """
    mock_seralization.task_status.return_value = {'status': 'mock'}
    mock_seralization.spawned_tasks.return_value = {'spawned_task': 'mock'}
    mock_seralization.task_result_href.return_value = {'_href': '/mock/path/'}

    task = {'task_id': 'mock_task'}
    serialized_task = task_serializer(task)
    mock_seralization.task_status.assert_called_once()
    mock_seralization.spawned_tasks.assert_called_once()
    mock_seralization.task_result_href.assert_called_once()

    expected_task = {'status': 'mock', 'spawned_task': 'mock', '_href': '/mock/path/'}
    if serialized_task != expected_task:
        raise AssertionError("Task serializer did not generate expected task. \n" +
                             "Task: {}, \nExpected Task: {}".format(serialized_task, expected_task))