Skip to content

Commit 82f31b0

Browse files
committed
Lookup multiple actions
1 parent 8710c87 commit 82f31b0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

jbi/runner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ def lookup_actions(bug: bugzilla_models.Bug, actions: Actions) -> list[Action]:
6767
"""
6868

6969
if bug.whiteboard:
70+
relevant_actions = []
7071
for tag, action in actions.by_tag.items():
7172
# [tag-word], [tag-], [tag], but not [word-tag] or [tagword]
7273
search_string = r"\[" + tag + r"(-[^\]]*)*\]"
7374
if re.search(search_string, bug.whiteboard, flags=re.IGNORECASE):
74-
return [action]
75+
relevant_actions.append(action)
76+
if len(relevant_actions):
77+
return relevant_actions
7578

7679
raise ActionNotFoundError(", ".join(actions.by_tag.keys()))
7780

tests/unit/test_runner.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
import requests
66
import responses
7+
import tests.fixtures.factories as factories
78

89
from jbi import Operation
910
from jbi.bugzilla.client import BugNotAccessibleError
@@ -624,6 +625,35 @@ def test_lookup_action_found(whiteboard, actions, bug_factory):
624625
assert "test config" in action.description
625626

626627

628+
@pytest.mark.parametrize(
629+
"whiteboard,expected_tags",
630+
[
631+
("[example][DevTest]", ["devtest"]),
632+
("[DevTest][example]", ["devtest"]),
633+
("[example][DevTest][other]", ["devtest", "other"]),
634+
],
635+
)
636+
def test_multiple_lookup_actions_found(whiteboard, expected_tags, bug_factory):
637+
actions = factories.ActionsFactory(root=[
638+
factories.ActionFactory(
639+
whiteboard_tag="devtest",
640+
bugzilla_user_id="tbd",
641+
description="test config",
642+
),
643+
factories.ActionFactory(
644+
whiteboard_tag="other",
645+
bugzilla_user_id="tbd",
646+
description="test config",
647+
),
648+
])
649+
bug = bug_factory(id=1234, whiteboard=whiteboard)
650+
acts = lookup_actions(bug, actions)
651+
assert len(acts) == len(expected_tags)
652+
looked_up_tags = [a.whiteboard_tag for a in acts]
653+
assert sorted(looked_up_tags) == sorted(expected_tags)
654+
assert all(["test config" == a.description for a in acts])
655+
656+
627657
@pytest.mark.parametrize(
628658
"whiteboard",
629659
[

0 commit comments

Comments
 (0)