Ejemplo n.º 1
0
    def test_no_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info produces the correct logs."""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {}

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "", "gae_latency_seconds": 1.5, '
            '"task_eta": 0.0, "execution_count": ""}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)
Ejemplo n.º 2
0
    def test_no_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info produces the correct logs."""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {}

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "", "gae_latency_seconds": 1.5, '
            '"task_eta": 0.0, "execution_count": ""}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)
Ejemplo n.º 3
0
    def test_all_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info produces the correct logs."""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {
            'X-Appengine-Taskretrycount': 'blue',
            'X-Appengine-Taskexecutioncount': 'yellow',
            'X-Appengine-Tasketa': '0.50'
        }

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "blue", "gae_latency_seconds": 1.0, '
            '"task_eta": 0.5, "execution_count": "yellow"}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)
Ejemplo n.º 4
0
    def test_all_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info produces the correct logs."""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {
            'X-Appengine-Taskretrycount': 'blue',
            'X-Appengine-Taskexecutioncount': 'yellow',
            'X-Appengine-Tasketa': '0.50'
        }

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "blue", "gae_latency_seconds": 1.0, '
            '"task_eta": 0.5, "execution_count": "yellow"}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)
Ejemplo n.º 5
0
    def test_ignore_extra_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info ignores extra items in the header"""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {
            'something-something': 'please-ignore-me',
            'X-Appengine-Taskretrycount': 'blue',
            'X-Appengine-Taskexecutioncount': 'yellow',
            'X-Appengine-Tasketa': '0.50'
        }

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "blue", "gae_latency_seconds": 1.0, '
            '"task_eta": 0.5, "execution_count": "yellow"}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)
Ejemplo n.º 6
0
    def test_ignore_extra_headers(self, debug_mock, time_mock):
        """Ensure _log_task_info ignores extra items in the header"""
        from furious import handlers
        time_mock.return_value = 1.5
        headers = {
            'something-something': 'please-ignore-me',
            'X-Appengine-Taskretrycount': 'blue',
            'X-Appengine-Taskexecutioncount': 'yellow',
            'X-Appengine-Tasketa': '0.50'
        }

        handlers._log_task_info(headers)

        expected_logs = (
            '{"ran": 1.5, "retry_count": "blue", "gae_latency_seconds": 1.0, '
            '"task_eta": 0.5, "execution_count": "yellow"}')

        debug_mock.assert_called_with('TASK-INFO: %s', expected_logs)