You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/06/08 18:28:00 UTC

[airflow] branch main updated: Fix: JiraOperator support any return response from Jira client (#31672)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ab8c9ec254 Fix: JiraOperator support any return response from Jira client (#31672)
ab8c9ec254 is described below

commit ab8c9ec2545caefb232d8e979b18b4c8c8ad3563
Author: Joffrey Bienvenu <jo...@gmail.com>
AuthorDate: Thu Jun 8 20:27:49 2023 +0200

    Fix: JiraOperator support any return response from Jira client (#31672)
    
    
    ---------
    
    Co-authored-by: Joffrey Bienvenu <jo...@infrabel.be>
---
 airflow/providers/atlassian/jira/operators/jira.py    |  4 ++--
 tests/providers/atlassian/jira/operators/test_jira.py | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/airflow/providers/atlassian/jira/operators/jira.py b/airflow/providers/atlassian/jira/operators/jira.py
index e5d806b167..90a8e945c7 100644
--- a/airflow/providers/atlassian/jira/operators/jira.py
+++ b/airflow/providers/atlassian/jira/operators/jira.py
@@ -75,9 +75,9 @@ class JiraOperator(BaseOperator):
             hook = JiraHook(jira_conn_id=self.jira_conn_id)
             resource = hook.client
 
-        jira_result = getattr(resource, self.method_name)(**self.jira_method_args)
+        jira_result: Any = getattr(resource, self.method_name)(**self.jira_method_args)
 
-        output = jira_result.get("id", None) if jira_result is not None else None
+        output = jira_result.get("id", None) if isinstance(jira_result, dict) else None
         self.xcom_push(context, key="id", value=output)
 
         if self.result_processor:
diff --git a/tests/providers/atlassian/jira/operators/test_jira.py b/tests/providers/atlassian/jira/operators/test_jira.py
index 32e57992d8..101df03d3f 100644
--- a/tests/providers/atlassian/jira/operators/test_jira.py
+++ b/tests/providers/atlassian/jira/operators/test_jira.py
@@ -60,6 +60,22 @@ class TestJiraOperator:
         assert jira_operator.result_processor is None
         assert jira_operator.get_jira_resource_method is None
 
+    @patch("airflow.providers.atlassian.jira.hooks.jira.Jira", autospec=True, return_value=jira_client_mock)
+    def test_project_issue_count(self, jira_mock):
+        jira_mock.return_value.get_project_issues_count.return_value = 10
+
+        jira_ticket_search_operator = JiraOperator(
+            task_id="get-issue-count",
+            jira_method="get_project_issues_count",
+            jira_method_args={"project": "ABC"},
+            dag=self.dag,
+        )
+
+        jira_ticket_search_operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True)
+
+        assert jira_mock.called
+        assert jira_mock.return_value.get_project_issues_count.called
+
     @patch("airflow.providers.atlassian.jira.hooks.jira.Jira", autospec=True, return_value=jira_client_mock)
     def test_issue_search(self, jira_mock):
         jql_str = "issuekey=TEST-1226"