# Path: kale/message.py
# class KaleMessage:
#     def __init__(self,
#                  sqs_message_id=None,
#                  sqs_receipt_handle=None,
#                  sqs_queue_name=None,
#                  task_class=None,
#                  task_name=None,
#                  task_id=None,
#                  payload=None,
#                  current_retry_num=None,
#                  current_failure_num=None,
#                  enqueued_time=None,
#                  publisher_data=None,
#                  instantiate_task=False,
#                  delete_func=None
#                  ):
#     def _validate_task_payload(payload):
#     def _get_message_body(self):
#     def encode(self):
#     def decode_sqs(cls, sqs_message):
#     def decode_str(cls, message_str):
#     def _class_from_path(self, task_path):
#     def delete(self):
# 
# Path: kale/task.py
# PERMANENT_FAILURE_UNRECOVERABLE = 'unrecoverable'
# PERMANENT_FAILURE_NO_RETRY = 'no_retries'
# PERMANENT_FAILURE_RETRIES_EXCEEDED = 'max_retries'
#     EXCEPTION_LIST = (
#         exceptions.BlacklistedException,
#         KeyError,
#         NotImplementedError,
#         SyntaxError,
#         UnboundLocalError)
# class Task(object):
#     def __init__(self, message_body=None, *args, **kwargs):
#     def _get_publisher():
#     def _get_task_id(cls, *args, **kwargs):
#     def publish(cls, app_data, *args, **kwargs):
#     def _get_delay_sec_for_retry(cls, current_retry_num):
#     def handle_failure(cls, message, raised_exception, increment_failure_num=True):
#     def republish(cls, message, failure_count):
#     def run(self, *args, **kwargs):
#     def run_task(self, *args, **kwargs):
#     def should_run_task(self, *args, **kwargs):
#     def _check_blacklist(self, *args, **kwargs):
#     def _dequeued(self, *args, **kwargs):
#     def _setup_task_environment():
#     def _clean_task_environment(task_id=None, task_name=None, exc=None):
#     def _pre_run(self, *args, **kwargs):
#     def _post_run(self, *args, **kwargs):
#     def _alert_runtime_exceeded(self, *args, **kwargs):
#     def _kill_runtime_exceeded(self, *args, **kwargs):
#     def _report_permanent_failure(cls, message, exception, failure_type,
#                                   log_exception):


import unittest
import mock
from kale import message
from kale import task





def _time_function():
    return 123


def _get_publisher_data():
    return 'test_publisher'


class MessageTestCase(unittest.TestCase):
    """Test KaleMessage."""

    def test_validate_message(self):
        payload = {'args': [], 'kwargs': {}}
        message.KaleMessage._validate_task_payload(payload)

    def test_validate_message_with_appdata(self):
        payload = {'args': [], 'kwargs': {}, 'app_data': {}}
        message.KaleMessage._validate_task_payload(payload)

    @mock.patch('kale.message._get_current_timestamp')
    def test_message(self, mock_get_current_timestamp):
        mock_get_current_timestamp.return_value = 123
        payload = {'args': [], 'kwargs': {}}

        # Test create

# Path: kale/message.py
# class KaleMessage:
#     def __init__(self,
#                  sqs_message_id=None,
#                  sqs_receipt_handle=None,
#                  sqs_queue_name=None,
#                  task_class=None,
#                  task_name=None,
#                  task_id=None,
#                  payload=None,
#                  current_retry_num=None,
#                  current_failure_num=None,
#                  enqueued_time=None,
#                  publisher_data=None,
#                  instantiate_task=False,
#                  delete_func=None
#                  ):
#     def _validate_task_payload(payload):
#     def _get_message_body(self):
#     def encode(self):
#     def decode_sqs(cls, sqs_message):
#     def decode_str(cls, message_str):
#     def _class_from_path(self, task_path):
#     def delete(self):
# 
# Path: kale/task.py
# PERMANENT_FAILURE_UNRECOVERABLE = 'unrecoverable'
# PERMANENT_FAILURE_NO_RETRY = 'no_retries'
# PERMANENT_FAILURE_RETRIES_EXCEEDED = 'max_retries'
#     EXCEPTION_LIST = (
#         exceptions.BlacklistedException,
#         KeyError,
#         NotImplementedError,
#         SyntaxError,
#         UnboundLocalError)
# class Task(object):
#     def __init__(self, message_body=None, *args, **kwargs):
#     def _get_publisher():
#     def _get_task_id(cls, *args, **kwargs):
#     def publish(cls, app_data, *args, **kwargs):
#     def _get_delay_sec_for_retry(cls, current_retry_num):
#     def handle_failure(cls, message, raised_exception, increment_failure_num=True):
#     def republish(cls, message, failure_count):
#     def run(self, *args, **kwargs):
#     def run_task(self, *args, **kwargs):
#     def should_run_task(self, *args, **kwargs):
#     def _check_blacklist(self, *args, **kwargs):
#     def _dequeued(self, *args, **kwargs):
#     def _setup_task_environment():
#     def _clean_task_environment(task_id=None, task_name=None, exc=None):
#     def _pre_run(self, *args, **kwargs):
#     def _post_run(self, *args, **kwargs):
#     def _alert_runtime_exceeded(self, *args, **kwargs):
#     def _kill_runtime_exceeded(self, *args, **kwargs):
#     def _report_permanent_failure(cls, message, exception, failure_type,
#                                   log_exception):


# Path: kale/tests/test_message.py
import unittest
import mock
from kale import message
from kale import task






def _time_function():
    return 123


def _get_publisher_data():
    return 'test_publisher'


class MessageTestCase(unittest.TestCase):
    """Test KaleMessage."""

    def test_validate_message(self):
        payload = {'args': [], 'kwargs': {}}
        message.KaleMessage._validate_task_payload(payload)

    def test_validate_message_with_appdata(self):
        payload = {'args': [], 'kwargs': {}, 'app_data': {}}
        message.KaleMessage._validate_task_payload(payload)

    @mock.patch('kale.message._get_current_timestamp')
    def test_message(self, mock_get_current_timestamp):
        mock_get_current_timestamp.return_value = 123
        payload = {'args': [], 'kwargs': {}}

        # Test create

        kale_msg = message.KaleMessage(