Skip to content

Commit

Permalink
Make setting of bz component more clear in BBSync
Browse files Browse the repository at this point in the history
  • Loading branch information
jobselko committed Jun 20, 2024
1 parent 9babbc2 commit 80daae5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 3 additions & 1 deletion apps/bbsync/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def generate_component(self):
generate component to differentiate between flaw and flaw draft
"""
self._query["component"] = (
"vulnerability-draft" if self.flaw.is_draft else "vulnerability"
"vulnerability-draft"
if self.flaw.workflow_state == Flaw.WorkflowState.NEW
else "vulnerability"
)

def generate_unconditional(self):
Expand Down
22 changes: 10 additions & 12 deletions apps/bbsync/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,24 +193,22 @@ def test_generate_summary_removed_cve(self):
assert bbq.query["summary"] == "hammer: is too heavy"

@pytest.mark.parametrize(
"is_draft,result",
"workflow_state,result",
[
(True, "vulnerability-draft"),
(False, "vulnerability"),
(WorkflowModel.WorkflowState.NOVALUE, "vulnerability"),
(WorkflowModel.WorkflowState.NEW, "vulnerability-draft"),
(WorkflowModel.WorkflowState.TRIAGE, "vulnerability"),
(WorkflowModel.WorkflowState.PRE_SECONDARY_ASSESSMENT, "vulnerability"),
(WorkflowModel.WorkflowState.SECONDARY_ASSESSMENT, "vulnerability"),
(WorkflowModel.WorkflowState.DONE, "vulnerability"),
(WorkflowModel.WorkflowState.REJECTED, "vulnerability"),
],
)
def test_generate_component(self, is_draft, result):
def test_generate_component(self, workflow_state, result):
"""
test generating of component
"""
flaw = FlawFactory(
cve_id="CVE-2000-1001",
workflow_state=WorkflowModel.WorkflowState.NEW,
meta_attr={
"bz_id": "1000",
"bz_component": "vulnerability-draft" if is_draft else "vulnerability",
},
)
flaw = FlawFactory(workflow_state=workflow_state)

bbq = FlawBugzillaQueryBuilder(flaw)
assert bbq.query["component"] == result
Expand Down

0 comments on commit 80daae5

Please sign in to comment.