def test_update_issue(self, jira_mock): jira_mock.return_value.add_comment.return_value = True add_comment_operator = JiraOperator(task_id='add_comment_test', jira_method="add_comment", jira_method_args={ 'issue': minimal_test_ticket.get("key"), 'body': 'this is test comment' }, dag=self.dag) add_comment_operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(jira_mock.called) self.assertTrue(jira_mock.return_value.add_comment.called)
def test_update_issue(self, jira_mock): jira_mock.return_value.add_comment.return_value = True add_comment_operator = JiraOperator(task_id='add_comment_test', jira_method="add_comment", jira_method_args={ 'issue': minimal_test_ticket.get("key"), 'body': 'this is test comment' }, dag=self.dag) add_comment_operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(jira_mock.called) self.assertTrue(jira_mock.return_value.add_comment.called)
def test_issue_search(self, jira_mock): jql_str = 'issuekey=TEST-1226' jira_mock.return_value.search_issues.return_value = minimal_test_ticket jira_ticket_search_operator = JiraOperator(task_id='search-ticket-test', jira_method="search_issues", jira_method_args={ 'jql_str': jql_str, 'maxResults': '1' }, dag=self.dag) jira_ticket_search_operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(jira_mock.called) self.assertTrue(jira_mock.return_value.search_issues.called)
def test_issue_search(self, jira_mock): jql_str = 'issuekey=TEST-1226' jira_mock.return_value.search_issues.return_value = minimal_test_ticket jira_ticket_search_operator = JiraOperator(task_id='search-ticket-test', jira_method="search_issues", jira_method_args={ 'jql_str': jql_str, 'maxResults': '1' }, dag=self.dag) jira_ticket_search_operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(jira_mock.called) self.assertTrue(jira_mock.return_value.search_issues.called)
def __init__(self, jira_conn_id='jira_default', method_name=None, method_params=None, result_processor=None, *args, **kwargs): super().__init__(*args, **kwargs) self.jira_conn_id = jira_conn_id self.result_processor = None if result_processor is not None: self.result_processor = result_processor self.method_name = method_name self.method_params = method_params self.jira_operator = JiraOperator(task_id=self.task_id, jira_conn_id=self.jira_conn_id, jira_method=self.method_name, jira_method_args=self.method_params, result_processor=self.result_processor)
def __init__(self, jira_conn_id='jira_default', method_name=None, method_params=None, result_processor=None, *args, **kwargs): super(JiraSensor, self).__init__(*args, **kwargs) self.jira_conn_id = jira_conn_id self.result_processor = None if result_processor is not None: self.result_processor = result_processor self.method_name = method_name self.method_params = method_params self.jira_operator = JiraOperator(task_id=self.task_id, jira_conn_id=self.jira_conn_id, jira_method=self.method_name, jira_method_args=self.method_params, result_processor=self.result_processor)
class JiraSensor(BaseSensorOperator): """ Monitors a jira ticket for any change. :param jira_conn_id: reference to a pre-defined Jira Connection :type jira_conn_id: str :param method_name: method name from jira-python-sdk to be execute :type method_name: str :param method_params: parameters for the method method_name :type method_params: dict :param result_processor: function that return boolean and act as a sensor response :type result_processor: function """ @apply_defaults def __init__(self, jira_conn_id='jira_default', method_name=None, method_params=None, result_processor=None, *args, **kwargs): super(JiraSensor, self).__init__(*args, **kwargs) self.jira_conn_id = jira_conn_id self.result_processor = None if result_processor is not None: self.result_processor = result_processor self.method_name = method_name self.method_params = method_params self.jira_operator = JiraOperator( task_id=self.task_id, jira_conn_id=self.jira_conn_id, jira_method=self.method_name, jira_method_args=self.method_params, result_processor=self.result_processor) def poke(self, context): return self.jira_operator.execute(context=context)
class JiraSensor(BaseSensorOperator): """ Monitors a jira ticket for any change. :param jira_conn_id: reference to a pre-defined Jira Connection :type jira_conn_id: str :param method_name: method name from jira-python-sdk to be execute :type method_name: str :param method_params: parameters for the method method_name :type method_params: dict :param result_processor: function that return boolean and act as a sensor response :type result_processor: function """ @apply_defaults def __init__(self, jira_conn_id='jira_default', method_name=None, method_params=None, result_processor=None, *args, **kwargs): super(JiraSensor, self).__init__(*args, **kwargs) self.jira_conn_id = jira_conn_id self.result_processor = None if result_processor is not None: self.result_processor = result_processor self.method_name = method_name self.method_params = method_params self.jira_operator = JiraOperator(task_id=self.task_id, jira_conn_id=self.jira_conn_id, jira_method=self.method_name, jira_method_args=self.method_params, result_processor=self.result_processor) def poke(self, context): return self.jira_operator.execute(context=context)