File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1081,12 +1081,14 @@ def _alias_or_int(_v):
10811081 else :
10821082 ids .append (idstr )
10831083
1084- if include_fields is not None and aliases and "alias" not in include_fields :
1084+ if (include_fields is not None and aliases
1085+ and "alias" not in include_fields ):
10851086 # Extra field to prevent sorting (see below) from cause an error
10861087 try :
10871088 include_fields .append ("alias" )
10881089 except AttributeError :
1089- # Just in case somebody passed in a tuple or another non-list type
1090+ # Just in case somebody passed in a tuple or another non-list
1091+ # type
10901092 include_fields = list (include_fields ) + ["alias" ]
10911093
10921094 extra_fields = listify (extra_fields or [])
Original file line number Diff line number Diff line change @@ -94,6 +94,28 @@ def test_api_getbugs():
9494 assert fakebz .getbugs (["123456" , "CVE-1234-FAKE" ]) == []
9595
9696
97+ def test_getbug_alias ():
98+ """
99+ Test that `getbug(<alias>)` includes the alias in `include_fields`
100+ """
101+ fakebz = tests .mockbackend .make_bz (
102+ bug_get_args = None ,
103+ bug_get_return = "data/mockreturn/test_query_cve_getbug.txt" )
104+ bug = fakebz .getbug ("CVE-1234-5678" , include_fields = ["id" ])
105+ assert bug .alias == ["CVE-1234-5678" ]
106+ assert bug .id == 123456
107+
108+ def mock_bug_get (bug_ids , aliases , paramdict ):
109+ assert bug_ids == []
110+ assert aliases == ["CVE-1234-5678" ]
111+ assert "alias" in paramdict .get ("include_fields" , [])
112+ return {"bugs" : [bug .get_raw_data ()]}
113+
114+ backend = getattr (fakebz , "_backend" )
115+ setattr (backend , "bug_get" , mock_bug_get )
116+ bug = fakebz .getbug ("CVE-1234-5678" , include_fields = ["id" ])
117+
118+
97119def test_bug_getattr ():
98120 fakebz = tests .mockbackend .make_bz (
99121 bug_get_args = None ,
You can’t perform that action at this time.
0 commit comments