def test_datahub_rest_hook(mock_emitter): with patch_airflow_connection(datahub_rest_connection_config) as config: hook = DatahubRestHook(config.conn_id) hook.emit_mces([lineage_mce]) mock_emitter.assert_called_once_with(config.host, None) instance = mock_emitter.return_value instance.emit_mce.assert_called_with(lineage_mce)
def __init__( self, *, datahub_rest_conn_id: Optional[str] = None, datahub_kafka_conn_id: Optional[str] = None, **kwargs, ): super().__init__(**kwargs) if datahub_rest_conn_id and datahub_kafka_conn_id: raise AirflowException( "two hook conn id given when only exactly one required") elif datahub_rest_conn_id: self.hook = DatahubRestHook(datahub_rest_conn_id) elif datahub_kafka_conn_id: self.hook = DatahubKafkaHook(datahub_kafka_conn_id) else: raise AirflowException("no hook conn id provided")