def test_add_label_by_query_with_results(self): j = Mock() jql = "assignee = john.doe" label = "somelabel" issue = Mock() issue.fields = Mock() issue.fields.labels = ["alpha", "beta", "gamma"] issue.update = Mock() j.search_issues = Mock(return_value=[issue]) jiralabels.add_label_by_query(j, jql, label).next() j.search_issues.assert_called_once_with(jql) issue.update.assert_called_once_with(labels=["alpha", "beta", "gamma", "somelabel"])
def test_add_label_by_query_with_no_results(self): j = Mock() jql = "assignee = john.doe" label = "somelabel" j.search_issues = Mock(return_value=[]) list(jiralabels.add_label_by_query(j, jql, label)) j.search_issues.assert_called_once_with(jql)