| |
@@ -134,7 +134,10 @@
|
| |
@patch("toddlers.utils.pagure.set_pagure")
|
| |
@patch("toddlers.utils.fedora_account.set_fasjson")
|
| |
@patch("toddlers.utils.bugzilla_system.set_bz")
|
| |
- def test_process_exception(self, mock_bugzilla, mock_fasjson, mock_pagure, toddler):
|
| |
+ @patch("toddlers.utils.anitya.set_anitya")
|
| |
+ def test_process_exception(
|
| |
+ self, mock_anitya, mock_bugzilla, mock_fasjson, mock_pagure, toddler
|
| |
+ ):
|
| |
"""
|
| |
Assert that message toddler will be initialized correctly, if message passes
|
| |
initial processing.
|
| |
@@ -180,12 +183,16 @@
|
| |
)
|
| |
mock_fasjson.assert_called_with(config)
|
| |
mock_bugzilla.assert_called_with(config)
|
| |
+ mock_anitya.assert_called_with(config)
|
| |
mock_pagure_io.add_comment_to_issue.assert_called_once()
|
| |
|
| |
+ @patch("toddlers.utils.anitya.set_anitya")
|
| |
@patch("toddlers.utils.pagure.set_pagure")
|
| |
@patch("toddlers.utils.fedora_account.set_fasjson")
|
| |
@patch("toddlers.utils.bugzilla_system.set_bz")
|
| |
- def test_process(self, mock_bugzilla, mock_fasjson, mock_pagure, toddler):
|
| |
+ def test_process(
|
| |
+ self, mock_bugzilla, mock_fasjson, mock_pagure, mock_anitya, toddler
|
| |
+ ):
|
| |
"""
|
| |
Assert that message toddler will be initialized correctly, if message passes
|
| |
initial processing.
|
| |
@@ -227,11 +234,15 @@
|
| |
)
|
| |
mock_fasjson.assert_called_with(config)
|
| |
mock_bugzilla.assert_called_with(config)
|
| |
+ mock_anitya.assert_called_with(config)
|
| |
|
| |
+ @patch("toddlers.utils.anitya.set_anitya")
|
| |
@patch("toddlers.utils.pagure.set_pagure")
|
| |
@patch("toddlers.utils.fedora_account.set_fasjson")
|
| |
@patch("toddlers.utils.bugzilla_system.set_bz")
|
| |
- def test_process_comment(self, mock_bugzilla, mock_fasjson, mock_pagure, toddler):
|
| |
+ def test_process_comment(
|
| |
+ self, mock_bugzilla, mock_fasjson, mock_pagure, mock_anitya, toddler
|
| |
+ ):
|
| |
"""
|
| |
Assert that toddler will handle comments correctly.
|
| |
"""
|
| |
@@ -791,6 +802,7 @@
|
| |
self.toddler = scm_request_processor.SCMRequestProcessor()
|
| |
self.toddler.pagure_io = Mock()
|
| |
self.toddler.dist_git = Mock()
|
| |
+ self.toddler.anitya = Mock()
|
| |
self.toddler.ping_comment = "{maintainers}"
|
| |
|
| |
def test_process_new_repo_missing_required_key(self):
|
| |
@@ -800,21 +812,32 @@
|
| |
issue = {
|
| |
"id": 100,
|
| |
}
|
| |
- self.toddler.process_new_repo(issue, {})
|
| |
+ json = {
|
| |
+ "repo": "+a",
|
| |
+ "branch": "rawhide",
|
| |
+ "namespace": "rpms",
|
| |
+ "bug_id": "123",
|
| |
+ "action": "new_repo",
|
| |
+ "sls": {"rawhide": "2050-06-01"},
|
| |
+ "monitor": "monitoring",
|
| |
+ }
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
|
| |
self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
100,
|
| |
namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
- message="Invalid body, missing required field: repo",
|
| |
+ message="Invalid body, missing required field: upstreamurl",
|
| |
reason="Invalid",
|
| |
)
|
| |
|
| |
- def test_process_new_repo_invalid_repo_name(self):
|
| |
+ def test_process_new_repo_missing_required_key_for_monitor(self):
|
| |
"""
|
| |
- Assert that ticket will be closed if provided repository name is invalid.
|
| |
+ Assert that ticket will be closed if required key for monitor
|
| |
+ is missing in request.
|
| |
"""
|
| |
- issue = {"id": 100, "user": {"name": "zlopez"}}
|
| |
-
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ }
|
| |
json = {
|
| |
"repo": "+a",
|
| |
"branch": "rawhide",
|
| |
@@ -822,40 +845,62 @@
|
| |
"bug_id": "123",
|
| |
"action": "new_repo",
|
| |
"sls": {"rawhide": "2050-06-01"},
|
| |
- "monitor": "monitor",
|
| |
+ "monitor": "monitoring",
|
| |
+ "upstreamurl": "",
|
| |
+ "backend": "GitLab",
|
| |
}
|
| |
-
|
| |
self.toddler.process_new_repo(issue, json)
|
| |
|
| |
- error = (
|
| |
- "The repository name is invalid. It must be at least two "
|
| |
- "characters long with only letters, numbers, hyphens, "
|
| |
- "underscores, plus signs, and/or periods. Please note that "
|
| |
- "the project cannot start with a period or a plus sign. "
|
| |
- "Repository name can't be longer than 64 characters."
|
| |
+ self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
+ 100,
|
| |
+ namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
+ message="Invalid body, missing required field: project_name",
|
| |
+ reason="Invalid",
|
| |
)
|
| |
|
| |
+ def test_process_new_repo_monitor_accepts_different_options(self):
|
| |
+ """
|
| |
+ Assert that ticket will be closed if required key for monitor
|
| |
+ is missing in request.
|
| |
+ """
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ }
|
| |
+ json = {
|
| |
+ "repo": "+a",
|
| |
+ "branch": "rawhide",
|
| |
+ "namespace": "rpms",
|
| |
+ "bug_id": "123",
|
| |
+ "action": "new_repo",
|
| |
+ "sls": {"rawhide": "2050-06-01"},
|
| |
+ "monitor": "monitoring11",
|
| |
+ "upstreamurl": "",
|
| |
+ "backend": "GitLab",
|
| |
+ }
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
+
|
| |
self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
100,
|
| |
namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
- message=error,
|
| |
+ message="Invalid body, missing required field: project_name",
|
| |
reason="Invalid",
|
| |
)
|
| |
|
| |
- def test_process_new_repo_long_repo_name(self):
|
| |
+ def test_process_new_repo_invalid_repo_name(self):
|
| |
"""
|
| |
Assert that ticket will be closed if provided repository name is invalid.
|
| |
"""
|
| |
issue = {"id": 100, "user": {"name": "zlopez"}}
|
| |
|
| |
json = {
|
| |
- "repo": "".join("a" for _ in range(65)),
|
| |
+ "repo": "+a",
|
| |
"branch": "rawhide",
|
| |
"namespace": "rpms",
|
| |
"bug_id": "123",
|
| |
"action": "new_repo",
|
| |
"sls": {"rawhide": "2050-06-01"},
|
| |
- "monitor": "monitor",
|
| |
+ "monitor": "no-monitoring",
|
| |
+ "upstreamurl": "",
|
| |
}
|
| |
|
| |
self.toddler.process_new_repo(issue, json)
|
| |
@@ -888,7 +933,8 @@
|
| |
"bug_id": "",
|
| |
"action": "new_repo",
|
| |
"sls": {"rawhide": "2050-06-01"},
|
| |
- "monitor": "monitor",
|
| |
+ "monitor": "no-monitoring",
|
| |
+ "upstreamurl": "",
|
| |
}
|
| |
|
| |
self.toddler.dist_git.get_project.return_value = None
|
| |
@@ -917,7 +963,8 @@
|
| |
"bug_id": "123",
|
| |
"action": "new_repo",
|
| |
"sls": {"rawhide": "2050-06-01"},
|
| |
- "monitor": "monitor",
|
| |
+ "monitor": "no-monitoring",
|
| |
+ "upstreamurl": "",
|
| |
}
|
| |
|
| |
self.toddler.dist_git.get_project.return_value = None
|
| |
@@ -951,7 +998,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {"rawhide": "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -961,6 +1009,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -990,7 +1039,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {"rawhide": "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1000,6 +1050,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -1020,7 +1071,10 @@
|
| |
comment=message,
|
| |
)
|
| |
|
| |
- def test_process_new_repo_master_branch(self):
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor.validate_review_bug"
|
| |
+ )
|
| |
+ def test_process_new_repo_master_branch(self, mock_validate_review_bug):
|
| |
"""
|
| |
Assert that ticket will be closed when branch is set to master branch.
|
| |
Master branch is no longer allowed.
|
| |
@@ -1033,7 +1087,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {"rawhide": "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1043,6 +1098,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
self.toddler.dist_git.get_project.return_value = None
|
| |
@@ -1068,7 +1124,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {"rawhide": "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1078,6 +1135,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
self.toddler.process_new_repo(issue, json)
|
| |
@@ -1120,11 +1178,12 @@
|
| |
}
|
| |
|
| |
repo = "repo"
|
| |
- bug_id = ""
|
| |
+ bug_id = "11"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
- exception = True
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
+ exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
"branch": branch,
|
| |
@@ -1133,6 +1192,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
dist_git_url = "https://src.fp.o"
|
| |
@@ -1141,9 +1201,12 @@
|
| |
self.toddler.pagure_io.get_project_contributors.return_value = {
|
| |
"users": {"admin": [user], "commit": [], "ticket": []}
|
| |
}
|
| |
+ self.toddler.validation_comment = "valid"
|
| |
+ self.toddler.validate_review_bug = Mock()
|
| |
|
| |
# Method to test
|
| |
- self.toddler.process_new_repo(issue, json)
|
| |
+ with patch("toddlers.plugins.scm_request_processor.bugzilla_system"):
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
|
| |
# asserts
|
| |
self.toddler.pagure_io.add_comment_to_issue.assert_called_with(
|
| |
@@ -1176,7 +1239,8 @@
|
| |
bug_id = ""
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = True
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1186,6 +1250,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
dist_git_url = "https://src.fp.o"
|
| |
@@ -1203,9 +1268,10 @@
|
| |
|
| |
@patch("toddlers.plugins.scm_request_processor.bugzilla_system")
|
| |
@patch(
|
| |
- "toddlers.plugins.scm_request_processor.SCMRequestProcessor.validate_review_bug"
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor._validate_new_repo_request",
|
| |
+ return_value=True,
|
| |
)
|
| |
- def test_process_new_repo_project_exists(self, mock_validate_review_bug, mock_bz):
|
| |
+ def test_process_new_repo_project_exists(self, mock_validate_request, mock_bz):
|
| |
"""
|
| |
Assert that ticket will be processed correctly when repo already
|
| |
exists in dist git.
|
| |
@@ -1218,7 +1284,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {"rawhide": "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1229,6 +1295,7 @@
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
"exception": exception,
|
| |
+ "upstreamurl": "",
|
| |
}
|
| |
|
| |
dist_git_url = "https://src.fp.o"
|
| |
@@ -1270,7 +1337,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1281,6 +1348,7 @@
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
"exception": exception,
|
| |
+ "upstreamurl": "",
|
| |
}
|
| |
self.toddler.branch_slas = {"rawhide": {"rawhide": "2050-06-01"}}
|
| |
|
| |
@@ -1322,6 +1390,314 @@
|
| |
)
|
| |
mock_bz.change_bug_status.assert_called_with(bug_id, "RELEASE_PENDING", message)
|
| |
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor._validate_new_repo_request",
|
| |
+ return_value=True,
|
| |
+ )
|
| |
+ def test_process_new_repo_monitoring_project_created_successfully_package_exist(
|
| |
+ self,
|
| |
+ mock_validate_request,
|
| |
+ ):
|
| |
+ """
|
| |
+ Assert that ticket will be processed with correct Monitoring message
|
| |
+ when project and package exists.
|
| |
+ """
|
| |
+ # Preparation
|
| |
+ user = "zlopez"
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ "user": {"name": user},
|
| |
+ }
|
| |
+
|
| |
+ repo = "repo"
|
| |
+ branch = "main"
|
| |
+ namespace = "tests"
|
| |
+ bug_id = ""
|
| |
+ action = "new_repo"
|
| |
+ sls = {branch: "2050-06-01"}
|
| |
+ monitor = "monitoring"
|
| |
+ upstreamurl = ""
|
| |
+ backend = "custom"
|
| |
+ distibution = "Fedora"
|
| |
+ project_name = "test_project"
|
| |
+ exception = False
|
| |
+ json = {
|
| |
+ "repo": repo,
|
| |
+ "branch": branch,
|
| |
+ "namespace": namespace,
|
| |
+ "bug_id": bug_id,
|
| |
+ "action": action,
|
| |
+ "sls": sls,
|
| |
+ "monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
+ "backend": backend,
|
| |
+ "distribution": distibution,
|
| |
+ "project_name": project_name,
|
| |
+ "exception": exception,
|
| |
+ }
|
| |
+ dist_git_url = "https://src.fp.o"
|
| |
+ self.toddler.dist_git._pagure_url = dist_git_url
|
| |
+ self.toddler.dist_git.get_project.return_value = {"access_users": {"owner": []}}
|
| |
+ anitya_project_url = "https://release-monitoring.org/project/123"
|
| |
+ self.toddler.anitya.does_project_exists_in_anitya = Mock(
|
| |
+ return_value=anitya_project_url
|
| |
+ )
|
| |
+ self.toddler.anitya.does_package_exists_in_anitya = Mock(return_value=True)
|
| |
+ project_msg = (
|
| |
+ "Anitya project is accessible by this link \n`{0}`\n "
|
| |
+ "you can modify it manually.".format(anitya_project_url)
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
+
|
| |
+ self.toddler.dist_git.set_monitoring_status.assert_called_with(
|
| |
+ namespace, repo, monitor
|
| |
+ )
|
| |
+ monitoring_msg = "\nMonitoring:\n{0}\n".format(project_msg)
|
| |
+
|
| |
+ message = "The Pagure repository was created at {0}/{1}/{2}{3}".format(
|
| |
+ dist_git_url, namespace, repo, monitoring_msg
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
+ 100,
|
| |
+ namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
+ message=message,
|
| |
+ reason="Processed",
|
| |
+ )
|
| |
+
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor._validate_new_repo_request",
|
| |
+ return_value=True,
|
| |
+ )
|
| |
+ def test_process_new_repo_monitoring_project_was_not_created(
|
| |
+ self,
|
| |
+ mock_validate_request,
|
| |
+ ):
|
| |
+ """
|
| |
+ Assert that ticket will be processed with correct Monitoring message
|
| |
+ when project and package exists.
|
| |
+ """
|
| |
+ # Preparation
|
| |
+ user = "zlopez"
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ "user": {"name": user},
|
| |
+ }
|
| |
+
|
| |
+ repo = "repo"
|
| |
+ branch = "main"
|
| |
+ namespace = "tests"
|
| |
+ bug_id = ""
|
| |
+ action = "new_repo"
|
| |
+ sls = {branch: "2050-06-01"}
|
| |
+ monitor = "monitoring"
|
| |
+ upstreamurl = ""
|
| |
+ backend = "custom"
|
| |
+ distibution = "Fedora"
|
| |
+ project_name = "test_project"
|
| |
+ exception = False
|
| |
+ json = {
|
| |
+ "repo": repo,
|
| |
+ "branch": branch,
|
| |
+ "namespace": namespace,
|
| |
+ "bug_id": bug_id,
|
| |
+ "action": action,
|
| |
+ "sls": sls,
|
| |
+ "monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
+ "backend": backend,
|
| |
+ "distribution": distibution,
|
| |
+ "project_name": project_name,
|
| |
+ "exception": exception,
|
| |
+ }
|
| |
+ dist_git_url = "https://src.fp.o"
|
| |
+ self.toddler.dist_git._pagure_url = dist_git_url
|
| |
+ self.toddler.dist_git.get_project.return_value = {"access_users": {"owner": []}}
|
| |
+ self.toddler.anitya.does_project_exists_in_anitya = Mock(return_value=None)
|
| |
+ self.toddler.anitya.create_project_in_anitya = Mock(return_value=None)
|
| |
+ project_msg = (
|
| |
+ "Wasn't able to create project in Anitya. "
|
| |
+ "You can create it manually on: `https://release-monitoring.org`"
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
+
|
| |
+ self.toddler.dist_git.set_monitoring_status.assert_called_with(
|
| |
+ namespace, repo, monitor
|
| |
+ )
|
| |
+ monitoring_msg = "\nMonitoring:\n{0}\n".format(project_msg)
|
| |
+
|
| |
+ message = "The Pagure repository was created at {0}/{1}/{2}{3}".format(
|
| |
+ dist_git_url, namespace, repo, monitoring_msg
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
+ 100,
|
| |
+ namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
+ message=message,
|
| |
+ reason="Processed",
|
| |
+ )
|
| |
+
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor._validate_new_repo_request",
|
| |
+ return_value=True,
|
| |
+ )
|
| |
+ def test_process_new_repo_monitoring_creating_package(
|
| |
+ self,
|
| |
+ mock_validate_request,
|
| |
+ ):
|
| |
+ """
|
| |
+ Assert that ticket will be processed with correct Monitoring message
|
| |
+ when project and package exists.
|
| |
+ """
|
| |
+ # Preparation
|
| |
+ user = "zlopez"
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ "user": {"name": user},
|
| |
+ }
|
| |
+
|
| |
+ repo = "repo"
|
| |
+ branch = "main"
|
| |
+ namespace = "tests"
|
| |
+ bug_id = ""
|
| |
+ action = "new_repo"
|
| |
+ sls = {branch: "2050-06-01"}
|
| |
+ monitor = "monitoring"
|
| |
+ upstreamurl = ""
|
| |
+ backend = "custom"
|
| |
+ distibution = "Fedora"
|
| |
+ project_name = "test_project"
|
| |
+ exception = False
|
| |
+ json = {
|
| |
+ "repo": repo,
|
| |
+ "branch": branch,
|
| |
+ "namespace": namespace,
|
| |
+ "bug_id": bug_id,
|
| |
+ "action": action,
|
| |
+ "sls": sls,
|
| |
+ "monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
+ "backend": backend,
|
| |
+ "distribution": distibution,
|
| |
+ "project_name": project_name,
|
| |
+ "exception": exception,
|
| |
+ }
|
| |
+ dist_git_url = "https://src.fp.o"
|
| |
+ self.toddler.dist_git._pagure_url = dist_git_url
|
| |
+ self.toddler.dist_git.get_project.return_value = {"access_users": {"owner": []}}
|
| |
+ anitya_project_url = "https://release-monitoring.org/project/123"
|
| |
+ self.toddler.anitya.does_project_exists_in_anitya = Mock(
|
| |
+ return_value=anitya_project_url
|
| |
+ )
|
| |
+ self.toddler.anitya.does_package_exists_in_anitya = Mock(return_value=False)
|
| |
+ self.toddler.anitya.create_package_in_anitya = Mock(return_value="Success")
|
| |
+ project_msg = (
|
| |
+ "Anitya project is accessible by this link \n`{0}`\n "
|
| |
+ "you can modify it manually.".format(anitya_project_url)
|
| |
+ )
|
| |
+ package_msg = "Package was created in Anitya"
|
| |
+
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
+
|
| |
+ self.toddler.dist_git.set_monitoring_status.assert_called_with(
|
| |
+ namespace, repo, monitor
|
| |
+ )
|
| |
+ monitoring_msg = "\nMonitoring:\n{0}\n{1}".format(project_msg, package_msg)
|
| |
+
|
| |
+ message = "The Pagure repository was created at {0}/{1}/{2}{3}".format(
|
| |
+ dist_git_url, namespace, repo, monitoring_msg
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
+ 100,
|
| |
+ namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
+ message=message,
|
| |
+ reason="Processed",
|
| |
+ )
|
| |
+
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.scm_request_processor.SCMRequestProcessor._validate_new_repo_request",
|
| |
+ return_value=True,
|
| |
+ )
|
| |
+ def test_process_new_repo_monitoring_creating_package_fails(
|
| |
+ self,
|
| |
+ mock_validate_request,
|
| |
+ ):
|
| |
+ """
|
| |
+ Assert that ticket will be processed with correct Monitoring message
|
| |
+ when project and package exists.
|
| |
+ """
|
| |
+ # Preparation
|
| |
+ user = "zlopez"
|
| |
+ issue = {
|
| |
+ "id": 100,
|
| |
+ "user": {"name": user},
|
| |
+ }
|
| |
+
|
| |
+ repo = "repo"
|
| |
+ branch = "main"
|
| |
+ namespace = "tests"
|
| |
+ bug_id = ""
|
| |
+ action = "new_repo"
|
| |
+ sls = {branch: "2050-06-01"}
|
| |
+ monitor = "monitoring"
|
| |
+ upstreamurl = ""
|
| |
+ backend = "custom"
|
| |
+ distibution = "Fedora"
|
| |
+ project_name = "test_project"
|
| |
+ exception = False
|
| |
+ json = {
|
| |
+ "repo": repo,
|
| |
+ "branch": branch,
|
| |
+ "namespace": namespace,
|
| |
+ "bug_id": bug_id,
|
| |
+ "action": action,
|
| |
+ "sls": sls,
|
| |
+ "monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
+ "backend": backend,
|
| |
+ "distribution": distibution,
|
| |
+ "project_name": project_name,
|
| |
+ "exception": exception,
|
| |
+ }
|
| |
+ dist_git_url = "https://src.fp.o"
|
| |
+ self.toddler.dist_git._pagure_url = dist_git_url
|
| |
+ self.toddler.dist_git.get_project.return_value = {"access_users": {"owner": []}}
|
| |
+ anitya_project_url = "https://release-monitoring.org/project/123"
|
| |
+ self.toddler.anitya.does_project_exists_in_anitya = Mock(
|
| |
+ return_value=anitya_project_url
|
| |
+ )
|
| |
+ self.toddler.anitya.does_package_exists_in_anitya = Mock(return_value=False)
|
| |
+ response_msg = "Unauthorized, access token is incorrect."
|
| |
+ self.toddler.anitya.create_package_in_anitya = Mock(return_value=response_msg)
|
| |
+ project_msg = (
|
| |
+ "Anitya project is accessible by this link \n`{0}`\n "
|
| |
+ "you can modify it manually.".format(anitya_project_url)
|
| |
+ )
|
| |
+ package_msg = "Package wasn't created in Anitya, reason: `{0}`.".format(
|
| |
+ response_msg
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.process_new_repo(issue, json)
|
| |
+
|
| |
+ self.toddler.dist_git.set_monitoring_status.assert_called_with(
|
| |
+ namespace, repo, monitor
|
| |
+ )
|
| |
+ monitoring_msg = "\nMonitoring:\n{0}\n{1}".format(project_msg, package_msg)
|
| |
+
|
| |
+ message = "The Pagure repository was created at {0}/{1}/{2}{3}".format(
|
| |
+ dist_git_url, namespace, repo, monitoring_msg
|
| |
+ )
|
| |
+
|
| |
+ self.toddler.pagure_io.close_issue.assert_called_with(
|
| |
+ 100,
|
| |
+ namespace=scm_request_processor.PROJECT_NAMESPACE,
|
| |
+ message=message,
|
| |
+ reason="Processed",
|
| |
+ )
|
| |
+
|
| |
@patch("toddlers.plugins.scm_request_processor.bugzilla_system")
|
| |
@patch(
|
| |
"toddlers.plugins.scm_request_processor.SCMRequestProcessor.validate_review_bug"
|
| |
@@ -1341,7 +1717,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1351,6 +1728,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
self.toddler.branch_slas = {"rawhide": {"rawhide": "2050-06-01"}}
|
| |
@@ -1411,7 +1789,8 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
+ upstreamurl = ""
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1421,6 +1800,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": upstreamurl,
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -1473,7 +1853,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1483,6 +1863,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": "",
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -1542,7 +1923,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1552,6 +1933,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": "",
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -1627,7 +2009,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1637,6 +2019,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": "",
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
@@ -1703,7 +2086,7 @@
|
| |
bug_id = "123"
|
| |
action = "new_repo"
|
| |
sls = {branch: "2050-06-01"}
|
| |
- monitor = "monitor"
|
| |
+ monitor = "no-monitoring"
|
| |
exception = False
|
| |
json = {
|
| |
"repo": repo,
|
| |
@@ -1713,6 +2096,7 @@
|
| |
"action": action,
|
| |
"sls": sls,
|
| |
"monitor": monitor,
|
| |
+ "upstreamurl": "",
|
| |
"exception": exception,
|
| |
}
|
| |
|
| |
Signed-off-by: Anton Medvedev amedvede@redhat.com