Let's not comment on ticket we already commented on
If the last comment on the ticket is from your pagure_user ignore pagure.issue.comment.added topic. Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
parent
dd9402fccf
commit
d23aa93424
2 changed files with 41 additions and 1 deletions
|
@ -7,7 +7,7 @@ import re
|
|||
from unittest.mock import call, MagicMock, Mock, patch
|
||||
|
||||
import arrow
|
||||
from pagure_messages.issue_schema import IssueNewV1
|
||||
from pagure_messages.issue_schema import IssueCommentAddedV1, IssueNewV1
|
||||
import pytest
|
||||
|
||||
from toddlers.exceptions import ValidationError
|
||||
|
@ -100,6 +100,34 @@ class TestProcess:
|
|||
caplog.records[-1].message == "The issue 100 is not open. Skipping message."
|
||||
)
|
||||
|
||||
def test_process_comment_already_added(self, caplog, toddler):
|
||||
"""
|
||||
Assert that toddler will ignore comments that were already commented on by it.
|
||||
"""
|
||||
caplog.set_level(logging.INFO)
|
||||
|
||||
pagure_user = "pagure_user"
|
||||
config = {"pagure_user": pagure_user}
|
||||
|
||||
msg = IssueCommentAddedV1()
|
||||
msg.body = {
|
||||
"project": {"fullname": scm_request_processor.PROJECT_NAMESPACE},
|
||||
"issue": {"status": "Open", "comments": [{"user": {"name": pagure_user}}]},
|
||||
}
|
||||
|
||||
with patch(
|
||||
"toddlers.plugins.scm_request_processor.SCMRequestProcessor.process_ticket"
|
||||
) as mock_process_ticket:
|
||||
toddler.process(config, msg)
|
||||
|
||||
mock_process_ticket.assert_not_called()
|
||||
|
||||
assert caplog.records[
|
||||
-1
|
||||
].message == "Last comment is from {0}. Ignoring the message.".format(
|
||||
pagure_user
|
||||
)
|
||||
|
||||
@patch("toddlers.utils.pdc.set_pdc")
|
||||
@patch("toddlers.utils.pagure.set_pagure")
|
||||
@patch("toddlers.utils.fedora_account.set_fasjson")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue