Skip to content

Commit

Permalink
Fix checking of PR labels (#2334)
Browse files Browse the repository at this point in the history
Fix checking of PR labels

The labels are GithubLabel objects and not strings, so we need to check their name attribute.

RELEASE NOTES BEGIN
N/A
RELEASE NOTES END

Reviewed-by: František Lachman <flachman@redhat.com>
Reviewed-by: Laura Barcziová
  • Loading branch information
2 parents 577555c + cb60e6f commit d22622b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packit_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def pr_labels_match_configuration(
f"(label.present: {configured_labels_present}, label.absent: {configured_labels_absent})"
)

pr_labels = pull_request.labels
pr_labels = [label.name for label in pull_request.labels]
logger.info(f"Labels on PR: {pr_labels}")

return (
Expand Down
13 changes: 9 additions & 4 deletions tests/unit/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,15 @@ def test_koji_check_allowed_accounts(
"pr_labels,labels_present,labels_absent,should_pass",
(
([], [], [], True),
(["allowed-1"], [], ["skip-ci"], True),
(["allowed-1"], ["allowed-1"], ["skip-ci"], True),
(["allowed-1"], ["allowed-1"], ["skip-ci"], True),
(["allowed-1", "skip-ci"], ["allowed-1"], ["skip-ci"], False),
([flexmock(name="allowed-1")], [], ["skip-ci"], True),
([flexmock(name="allowed-1")], ["allowed-1"], ["skip-ci"], True),
([flexmock(name="allowed-1")], ["allowed-1"], ["skip-ci"], True),
(
[flexmock(name="allowed-1"), flexmock(name="skip-ci")],
["allowed-1"],
["skip-ci"],
False,
),
),
)
def test_labels_on_distgit_pr(
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,31 @@ def f(one, two, three="something"):
pytest.param(
[],
["my-label"],
["my-label"],
[flexmock(name="my-label")],
True,
),
pytest.param(
["skip-ci"],
["my-label"],
["my-label"],
[flexmock(name="my-label")],
True,
),
pytest.param(
["skip-ci"],
["my-label"],
["my-label", "skip-ci"],
[flexmock(name="my-label"), flexmock(name="skip-ci")],
False,
),
pytest.param(
["skip-ci"],
["my-label"],
["skip-ci"],
[flexmock(name="skip-ci")],
False,
),
pytest.param(
["skip-ci"],
[],
["skip-ci"],
[flexmock(name="skip-ci")],
False,
),
pytest.param(
Expand All @@ -126,19 +126,19 @@ def f(one, two, three="something"):
pytest.param(
["skip-ci"],
["first", "second"],
["second"],
[flexmock(name="second")],
True,
),
pytest.param(
["skip-ci"],
["first", "second"],
["third"],
[flexmock(name="third")],
False,
),
pytest.param(
["skip-ci", "block-ci"],
["first", "second"],
["block-ci"],
[flexmock(name="block-ci")],
False,
),
pytest.param(
Expand All @@ -150,7 +150,7 @@ def f(one, two, three="something"):
pytest.param(
[],
[],
["some-label"],
[flexmock(name="some-label")],
True,
),
],
Expand Down

0 comments on commit d22622b

Please sign in to comment.