Skip to content

Commit

Permalink
Test for fallback to title
Browse files Browse the repository at this point in the history
  • Loading branch information
lagru committed Jan 9, 2024
1 parent e99aa5f commit d22a760
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _MockPullRequest:


class Test_ChangeNote:
def test_from_pull_requests(self, caplog):
def test_from_pull_requests_multiple(self, caplog):
caplog.set_level("DEBUG")
body = """
Some ignored text in the pull request body.
Expand Down Expand Up @@ -68,3 +68,24 @@ def test_from_pull_requests(self, caplog):
assert len(caplog.records) == 1
assert caplog.records[0].levelname == "DEBUG"
assert "falling back to PR labels for summary" in caplog.records[0].msg

def test_from_pull_requests_fallback_title(self, caplog):
caplog.set_level("DEBUG")
pull_request = _MockPullRequest(
title='The title {label="ignored in title"}',
body="Nothing here.",
labels=[_MockLabel("Documentation")],
)
notes = ChangeNote.from_pull_requests(
[pull_request],
pr_summary_regex=DEFAULT_CONFIG["pr_summary_regex"],
pr_summary_label_regex=DEFAULT_CONFIG["pr_summary_label_regex"],
)
assert len(notes) == 1
notes = sorted(notes, key=lambda n: n.content)
assert notes[0].content == 'The title {label="ignored in title"}'
assert notes[0].labels == ("Documentation",)

assert len(caplog.records) == 1
assert caplog.records[0].levelname == "DEBUG"
assert "falling back to title" in caplog.records[0].msg

0 comments on commit d22a760

Please sign in to comment.