def test_custom_fields(): custom_field = "my_custom_field" custom_map = {custom_field: 1234} query = {custom_field: {"=": "BF"}} assert under_test.jql_from_dict( query, custom_map) == f"'cf[{custom_map[custom_field]}]' = BF"
def test_combinations(): query = { "and": [{ "project": { "=": "BF" } }, { "createdDate": { ">": "-365d" } }] } jql = under_test.jql_from_dict(query) assert jql.strip() == "('project' = BF) AND ('createdDate' > -365d)"
def search_issues(self, search: Dict, **kwargs: Optional[Dict]) -> Iterable[Any]: """ Search for jira issues. :param search: Dictionary specifying search parameters. :return: Iterable of issues found. """ jql = jql_from_dict(search, self._custom_field_map) def transform_fn(result: Issue) -> IssueWrapper: return IssueWrapper(result, self._custom_field_map) def get_more_fn(start_idx: int) -> ResultList: return self.jira.search_issues(jql, startAt=start_idx, **kwargs) return JiraResponseIterable(get_more_fn(0), transform_fn, get_more_fn)
def test_functions(): query = { "and": [ { "project": { "=": "BF" } }, { "issueFunction": { "in": { "linkedIssueOf": { "subquery": { "project": { "in": [ "TIG", "SERVER", "BACKPORT", "BUILD", "EVG", "MCI" ] } }, "linktype": "is depended on by", } } } }, { "createdDate": { ">": "-365d" } }, ] } jql = under_test.jql_from_dict(query) assert "('project' = BF)" in jql assert "('createdDate' > -365d)" in jql assert "AND" in jql
def test_operators(): query = {"project": {"=": "BF"}} assert under_test.jql_from_dict(query) == "'project' = BF"
def test_is_with_bad_value(): query = {"resolution": {"is": "something"}} with pytest.raises(ValueError): under_test.jql_from_dict(query)
def test_not_is_empty(): query = {"resolution": {"is not": "empty"}} assert under_test.jql_from_dict(query) == "'resolution' is not empty"