From d22a760080f211b9448a9dbb3a2038be55f3930c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gr=C3=BCter?= Date: Tue, 9 Jan 2024 17:13:19 +0100 Subject: [PATCH] Test for fallback to title --- test/test_objects.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_objects.py b/test/test_objects.py index 96c44c1..3f6c9cf 100644 --- a/test/test_objects.py +++ b/test/test_objects.py @@ -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. @@ -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