From fe5969f25beb69caf62cc8007ae98b12d5aa6300 Mon Sep 17 00:00:00 2001 From: ybonatakis Date: Thu, 16 May 2024 15:29:02 +0200 Subject: [PATCH 1/3] Fix message format on the second reminder https://progress.opensuse.org/issues/119176 Signed-off-by: ybonatakis --- backlogger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backlogger.py b/backlogger.py index b026a9f..13c3169 100755 --- a/backlogger.py +++ b/backlogger.py @@ -111,8 +111,8 @@ def _update_issue_priority(poo_id, priority_current, poo_reminder_state, msg): slo_priorities[priority_current]["next_priority"]["name"], poo_id)) url = "{}/{}.json".format(data["web"], poo_id) - msg = " ".join(update_slo_text.format( - priority=slo_priorities[priority_current]["next_priority"]["name"])) + msg = " ".join([reminder_text, update_slo_text.format( + priority=slo_priorities[priority_current]["next_priority"]["name"])]) json_rest("PUT", url, {"issue": {"priority_id": slo_priorities[priority_current]["next_priority"]["id"], From 1e15a22b2e1c269b3fc8118a441f23becc38ac2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Fri, 17 May 2024 14:33:13 +0200 Subject: [PATCH 2/3] Fix formatting of message and add test Issue: https://progress.opensuse.org/issues/119176 --- backlogger.py | 2 +- tests/test_comments.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backlogger.py b/backlogger.py index 13c3169..fa377ae 100755 --- a/backlogger.py +++ b/backlogger.py @@ -111,7 +111,7 @@ def _update_issue_priority(poo_id, priority_current, poo_reminder_state, msg): slo_priorities[priority_current]["next_priority"]["name"], poo_id)) url = "{}/{}.json".format(data["web"], poo_id) - msg = " ".join([reminder_text, update_slo_text.format( + msg = " ".join([reminder_text.format(priority=priority_current, url=data["url"]), update_slo_text.format( priority=slo_priorities[priority_current]["next_priority"]["name"])]) json_rest("PUT", url, {"issue": diff --git a/tests/test_comments.py b/tests/test_comments.py index b158f0a..e2e664c 100755 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -122,6 +122,23 @@ def test_automatic_priority_on_issue(self): out, err = self.capsys.readouterr() assert re.search(expected_str.format(params[0], params[1]), out) + calls = [ + call( + "GET", + "https://example.com/wiki/1000.json?include=journals", + ), + call( + "PUT", + "https://example.com/wiki/1000.json", + { + "issue": { + "priority_id": 3, + "notes": "This ticket was set to **Normal** priority but was not updated [within the SLO period](https://example.com/issues). Please consider picking up this ticket or just set the ticket to the next lower priority. The ticket will be set to the next lower priority **Low**." + } + }, + ), + ] + backlogger.json_rest.assert_has_calls(calls) def test_issue_with_low_priority_never_change(self): From 22e61c306f964de47ad768f726f183d6f0bfab18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Fri, 17 May 2024 15:23:51 +0200 Subject: [PATCH 3/3] Improve reminder text --- backlogger.py | 7 ++++--- tests/test_comments.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backlogger.py b/backlogger.py index fa377ae..a60d5e1 100755 --- a/backlogger.py +++ b/backlogger.py @@ -17,7 +17,8 @@ # Icons used for PASS or FAIL in the md file result_icons = {"pass": "💚", "fail": "🔴"} -reminder_text = "This ticket was set to **{priority}** priority but was not updated [within the SLO period]({url}). Please consider picking up this ticket or just set the ticket to the next lower priority." +reminder_text_common = "This ticket was set to **{priority}** priority but was not updated [within the SLO period]({url})." +reminder_text = "Please consider picking up this ticket or just set the ticket to the next lower priority." update_slo_text = "The ticket will be set to the next lower priority **{priority}**." reminder_regex = ( r"^This ticket was set to .* priority but was not updated.* Please consider" @@ -79,7 +80,7 @@ def json_rest(method, url, rest=None): def issue_reminder(conf, poo, poo_reminder_state): priority = poo["priority"]["name"] - msg = reminder_text.format(priority=priority, url=data["url"]) + msg = " ".join([reminder_text_common.format(priority=priority, url=data["url"]), reminder_text]) if "comment" in conf: msg = conf["comment"] if data["reminder-comment-on-issues"]: @@ -111,7 +112,7 @@ def _update_issue_priority(poo_id, priority_current, poo_reminder_state, msg): slo_priorities[priority_current]["next_priority"]["name"], poo_id)) url = "{}/{}.json".format(data["web"], poo_id) - msg = " ".join([reminder_text.format(priority=priority_current, url=data["url"]), update_slo_text.format( + msg = " ".join([reminder_text_common.format(priority=priority_current, url=data["url"]), update_slo_text.format( priority=slo_priorities[priority_current]["next_priority"]["name"])]) json_rest("PUT", url, {"issue": diff --git a/tests/test_comments.py b/tests/test_comments.py index e2e664c..443ca6f 100755 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -133,7 +133,7 @@ def test_automatic_priority_on_issue(self): { "issue": { "priority_id": 3, - "notes": "This ticket was set to **Normal** priority but was not updated [within the SLO period](https://example.com/issues). Please consider picking up this ticket or just set the ticket to the next lower priority. The ticket will be set to the next lower priority **Low**." + "notes": "This ticket was set to **Normal** priority but was not updated [within the SLO period](https://example.com/issues). The ticket will be set to the next lower priority **Low**." } }, ),