Notify the maintainers even if issue already contains a comment

Ping the maintainers if there is no comment from toddler user present yet. This
is a change from current behavior, when the comment was only done, when there
was no comment on the issue altogether.

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
Michal Konečný 2022-04-01 13:26:28 +02:00
parent 077a3f42a5
commit 401b425004
3 changed files with 93 additions and 18 deletions

View file

@ -564,7 +564,13 @@ class TestCreateNewRepo:
issue = {
"id": 100,
"user": {"name": user},
"comments": [{"comment": "valid", "user": {"name": invalid_user}}],
"comments": [
{
"comment": "valid",
"user": {"name": invalid_user},
"notification": False,
}
],
}
repo = "repo"
@ -608,7 +614,9 @@ class TestCreateNewRepo:
issue = {
"id": 100,
"user": {"name": user},
"comments": [{"comment": "comment", "user": {"name": user}}],
"comments": [
{"comment": "comment", "user": {"name": user}, "notification": False}
],
}
repo = "repo"
@ -687,6 +695,53 @@ class TestCreateNewRepo:
100, namespace=scm_request_processor.PROJECT_NAMESPACE, comment=message
)
def test_create_new_repo_exception_not_valid_notification_comment_present(self):
"""
Assert that comment will not be added if the toddler already commented on the
ticket.
"""
# Preparation
user = "zlopez"
issue = {
"id": 100,
"user": {"name": user},
"comments": [
{"comment": "comment", "user": {"name": user}, "notification": False}
],
}
repo = "repo"
branch = "main"
namespace = "tests"
bug_id = ""
action = "new_repo"
sls = {branch: "2050-06-01"}
monitor = "monitor"
exception = False
json = {
"repo": repo,
"branch": branch,
"namespace": namespace,
"bug_id": bug_id,
"action": action,
"sls": sls,
"monitor": monitor,
"exception": exception,
}
self.toddler.pagure_io.get_project_contributors.return_value = {
"users": {"admin": ["Tzeentch"], "commit": [], "ticket": []}
}
self.toddler.pagure_user = user
self.toddler.create_new_repo(issue, json)
# asserts
self.toddler.pagure_io.get_project_contributors.assert_called_with(
scm_request_processor.PROJECT_NAMESPACE.split("/")[0],
scm_request_processor.PROJECT_NAMESPACE.split("/")[1],
)
self.toddler.pagure_io.add_comment_to_issue.assert_not_called()
def test_create_new_repo_missing_bug_id(self):
"""
Assert that ticket will be closed if Bugzilla bug id is not provided.
@ -1054,7 +1109,9 @@ class TestCreateNewRepo:
issue = {
"id": 100,
"user": {"name": user},
"comments": [{"comment": "valid", "user": {"name": user}}],
"comments": [
{"comment": "valid", "user": {"name": user}, "notification": False}
],
}
repo = "repo"
@ -1128,7 +1185,9 @@ class TestCreateNewRepo:
issue = {
"id": 100,
"user": {"name": user},
"comments": [{"comment": "valid", "user": {"name": user}}],
"comments": [
{"comment": "valid", "user": {"name": user}, "notification": False}
],
}
repo = "repo"