Exemple #1
0
    def test_run_task(self, mock_hook):
        mock_hook.return_value.run_task.return_value = TEST_TASK
        operator = CloudTasksTaskRunOperator(location=LOCATION,
                                             queue_name=QUEUE_ID,
                                             task_name=TASK_NAME,
                                             task_id="id")

        result = operator.execute(context=None)

        assert {
            'app_engine_http_request': {
                'body': '',
                'headers': {},
                'http_method': 0,
                'relative_uri': ''
            },
            'dispatch_count': 0,
            'name': '',
            'response_count': 0,
            'view': 0,
        } == result
        mock_hook.assert_called_once_with(
            gcp_conn_id=GCP_CONN_ID,
            impersonation_chain=None,
        )
        mock_hook.return_value.run_task.assert_called_once_with(
            location=LOCATION,
            queue_name=QUEUE_ID,
            task_name=TASK_NAME,
            project_id=None,
            response_view=None,
            retry=None,
            timeout=None,
            metadata=None,
        )
Exemple #2
0
 def test_run_task(self, mock_hook):
     mock_hook.return_value.run_task.return_value = mock.MagicMock()
     operator = CloudTasksTaskRunOperator(
         location=LOCATION, queue_name=QUEUE_ID, task_name=TASK_NAME, task_id="id"
     )
     operator.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.run_task.assert_called_once_with(
         location=LOCATION,
         queue_name=QUEUE_ID,
         task_name=TASK_NAME,
         project_id=None,
         response_view=None,
         retry=None,
         timeout=None,
         metadata=None,
     )
Exemple #3
0
    def test_run_task(self, mock_hook):
        mock_hook.return_value.run_task.return_value = TEST_TASK
        operator = CloudTasksTaskRunOperator(location=LOCATION,
                                             queue_name=QUEUE_ID,
                                             task_name=TASK_NAME,
                                             task_id="id")

        result = operator.execute(context=None)

        self.assertEqual({'appEngineHttpRequest': {}}, result)
        mock_hook.assert_called_once_with(
            gcp_conn_id=GCP_CONN_ID,
            impersonation_chain=None,
        )
        mock_hook.return_value.run_task.assert_called_once_with(
            location=LOCATION,
            queue_name=QUEUE_ID,
            task_name=TASK_NAME,
            project_id=None,
            response_view=None,
            retry=None,
            timeout=None,
            metadata=None,
        )