Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit 699c894

Browse files
Add unit test
1 parent aa7f772 commit 699c894

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

highfive/tests/fakes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def get_repo_configs():
7575
"reviewers": ["@JohnTitor"],
7676
}
7777
}
78+
},
79+
'teams': {
80+
"groups": {"all": [], "a": ["@pnkfelix"], "b/c": ["@nrc"]}
7881
}
7982
}
8083

highfive/tests/test_newpr.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,31 @@ def test_mentions_without_dirs(self):
12601260
)
12611261
assert set(["@JohnTitor"]) == mentions
12621262

1263+
def test_with_team_ping(self):
1264+
"""Test choosing a reviewer when passed a team ping"""
1265+
handler = HighfiveHandlerMock(
1266+
Payload({}), repo_config=self.fakes['config']['teams']
1267+
).handler
1268+
1269+
found_cases = (
1270+
("r? @foo/a", "pnkfelix"),
1271+
("r? @b/c", "nrc"),
1272+
)
1273+
1274+
not_found_cases = (
1275+
"r? @/a",
1276+
"r? @a/b",
1277+
)
1278+
1279+
for (msg, reviewer) in found_cases:
1280+
assert handler.find_reviewer(msg, None) == reviewer, \
1281+
"expected '%s' from '%s'" % (reviewer, msg)
1282+
1283+
for msg in not_found_cases:
1284+
assert handler.find_reviewer(msg, None) is None, \
1285+
"expected '%s' to have no reviewer extracted" % msg
1286+
1287+
12631288
class TestRun(TestNewPR):
12641289
@pytest.fixture(autouse=True)
12651290
def make_mocks(cls, patcherize):

0 commit comments

Comments
 (0)