Beispiel #1
0
 def test_operation_get_should_throw_ex_when_operation_name_none(self, mock_hook):
     with self.assertRaises(AirflowException) as cm:
         op = CloudDataTransferServiceGetOperationOperator(operation_name="", task_id=TASK_ID)
         op.execute(None)
     err = cm.exception
     self.assertIn("The required parameter 'operation_name' is empty or None", str(err))
     mock_hook.assert_not_called()
 def test_operation_get(self, mock_hook):
     mock_hook.return_value.get_transfer_operation.return_value = VALID_OPERATION
     op = CloudDataTransferServiceGetOperationOperator(operation_name=OPERATION_NAME, task_id=TASK_ID)
     result = op.execute(None)
     mock_hook.assert_called_once_with(api_version='v1', gcp_conn_id='google_cloud_default')
     mock_hook.return_value.get_transfer_operation.assert_called_once_with(operation_name=OPERATION_NAME)
     self.assertEqual(result, VALID_OPERATION)
Beispiel #3
0
 def test_operation_get(self, mock_hook):
     mock_hook.return_value.get_transfer_operation.return_value = VALID_OPERATION
     op = CloudDataTransferServiceGetOperationOperator(
         operation_name=OPERATION_NAME,
         task_id=TASK_ID,
         google_impersonation_chain=IMPERSONATION_CHAIN,
     )
     result = op.execute(None)
     mock_hook.assert_called_once_with(
         api_version='v1',
         gcp_conn_id='google_cloud_default',
         impersonation_chain=IMPERSONATION_CHAIN,
     )
     mock_hook.return_value.get_transfer_operation.assert_called_once_with(
         operation_name=OPERATION_NAME)
     assert result == VALID_OPERATION