Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bugzilla/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,11 @@ def _alias_or_int(_v):
else:
ids.append(idstr)

if (include_fields is not None and aliases
and "alias" not in include_fields):
# Extra field to prevent sorting (see below) from causing an error
include_fields.append("alias")

extra_fields = listify(extra_fields or [])
extra_fields += self._getbug_extra_fields()

Expand Down
23 changes: 23 additions & 0 deletions tests/test_api_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ def test_api_getbugs():
assert fakebz.getbugs(["123456", "CVE-1234-FAKE"]) == []


def test_getbug_alias():
"""
Test that `getbug(<alias>)` includes the alias in `include_fields`
"""
fakebz = tests.mockbackend.make_bz(
bug_get_args=None,
bug_get_return="data/mockreturn/test_query_cve_getbug.txt")
bug = fakebz.getbug("CVE-1234-5678", include_fields=["id"])
assert bug.alias == ["CVE-1234-5678"]
assert bug.id == 123456

def mock_bug_get(bug_ids, aliases, paramdict):
assert bug_ids == []
assert aliases == ["CVE-1234-5678"]
assert "alias" in paramdict.get("include_fields", [])
return {"bugs": [bug.get_raw_data()]}

backend = getattr(fakebz, "_backend")
setattr(backend, "bug_get", mock_bug_get)

fakebz.getbug("CVE-1234-5678", include_fields=["id"])


def test_bug_getattr():
fakebz = tests.mockbackend.make_bz(
bug_get_args=None,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_ro_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ def testGetBugAlias404(backends):
raise AssertionError("No exception raised")


def testGetBugAliasIncludedField(backends):
bz = _open_bz(REDHAT_URL, **backends)

bug = bz.getbug("CVE-2011-2527", include_fields=["id"])
assert bug.bug_id == 720773


def testQuerySubComponent(run_cli, backends):
bz = _open_bz(REDHAT_URL, **backends)

Expand Down