| |
@@ -3,7 +3,7 @@
|
| |
"""
|
| |
import datetime
|
| |
import logging
|
| |
- from unittest.mock import patch, Mock, call, MagicMock
|
| |
+ from unittest.mock import call, MagicMock, Mock, patch
|
| |
|
| |
import git
|
| |
import koji
|
| |
@@ -28,7 +28,14 @@
|
| |
"""
|
| |
assert toddler.accepts_topic("foo.bar") is False
|
| |
|
| |
- @pytest.mark.parametrize("topic", ["io.pagure.prod.pagure.issue.new"])
|
| |
+ @pytest.mark.parametrize(
|
| |
+ "topic",
|
| |
+ [
|
| |
+ "io.pagure.*.pagure.issue.new",
|
| |
+ "io.pagure.stg.pagure.issue.new",
|
| |
+ "io.pagure.prod.pagure.issue.new",
|
| |
+ ],
|
| |
+ )
|
| |
def test_accepts_topic_valid(self, topic, toddler):
|
| |
"""
|
| |
Assert that valid topics are accepted.
|
| |
@@ -269,8 +276,10 @@
|
| |
},
|
| |
"id": 55,
|
| |
}
|
| |
- message = "Remote repository doesn't exist or you do not have " \
|
| |
- "the appropriate permissions to access it."
|
| |
+ message = (
|
| |
+ "Remote repository doesn't exist or you do not have "
|
| |
+ "the appropriate permissions to access it."
|
| |
+ )
|
| |
# self.toddler.git_repo.side_effect = git.GitCommandError
|
| |
with patch(
|
| |
"toddlers.plugins.pdc_unretire_packages.git.clone_repo",
|
| |
@@ -361,9 +370,7 @@
|
| |
self.toddler.pagure_io.assign_maintainer_to_project.assert_called_with(
|
| |
namespace=namespace, repo=repo, maintainer_fas=issue["user"]["name"]
|
| |
)
|
| |
- adjust_eol_pdc_mock.assert_called_with(
|
| |
- namespace, repo, tags_to_unblock
|
| |
- )
|
| |
+ adjust_eol_pdc_mock.assert_called_with(namespace, repo, tags_to_unblock)
|
| |
|
| |
assert caplog.records[-1].message == "everything was alright!"
|
| |
|
| |
@@ -420,18 +427,6 @@
|
| |
"""
|
| |
self.toddler = pdc_unretire_packages.PDCUnretirePackages()
|
| |
|
| |
- def test_get_namespace_and_repo_url_not_correct(self, caplog):
|
| |
- """
|
| |
- Assert that list of elements is too short
|
| |
- """
|
| |
- caplog.set_level(logging.INFO)
|
| |
- url = "https://src.fedoraproject.or" + "rpms/rubygem-logging" + ".git"
|
| |
-
|
| |
- assert self.toddler._get_namespace_and_repo(url) == (None, None)
|
| |
- assert caplog.records[-1].message == "Something wrong with url '{0}'".format(
|
| |
- url
|
| |
- )
|
| |
-
|
| |
def test_get_namespace_and_repo_url_with_suffix(self):
|
| |
"""
|
| |
Assert that get namespace and repo works fine when url contain suffix.
|
| |
@@ -618,8 +613,10 @@
|
| |
"""
|
| |
issue_id = 99
|
| |
commit_msg = "legal issue"
|
| |
- close_issue_msg = f"Package was retire because of legal or license issue. " \
|
| |
- f"Commit message '{commit_msg}'"
|
| |
+ close_issue_msg = (
|
| |
+ f"Package was retire because of legal or license issue. "
|
| |
+ f"Commit message '{commit_msg}'"
|
| |
+ )
|
| |
|
| |
self.toddler.git_repo.get_last_commit_message.return_value = commit_msg
|
| |
|
| |
@@ -661,14 +658,24 @@
|
| |
self.toddler.git_repo = Mock()
|
| |
self.toddler.pagure_io = Mock()
|
| |
|
| |
+ def test_is_last_commit_date_correct_date_date_is_none(self):
|
| |
+ """
|
| |
+ Assert that method will return false if git won't be able to find a date.
|
| |
+ """
|
| |
+ issue_id = 99
|
| |
+ self.toddler.git_repo.get_last_commit_date.return_value = None
|
| |
+ assert self.toddler._is_last_commit_date_correct(issue_id) is False
|
| |
+
|
| |
def test_is_last_commit_date_correct_date_not_correct(self):
|
| |
"""
|
| |
Assert that last commit was made more than 8 weeks ago
|
| |
"""
|
| |
issue_id = 99
|
| |
commit_date = 55
|
| |
- close_issue_msg = "Package can not be unretired, because retire commit was made more " \
|
| |
- "than 8 weeks ago."
|
| |
+ close_issue_msg = (
|
| |
+ "Package can not be unretired, because retire commit was made more "
|
| |
+ "than 8 weeks ago."
|
| |
+ )
|
| |
|
| |
self.toddler.git_repo.get_last_commit_date.return_value = commit_date
|
| |
|
| |
@@ -764,7 +771,9 @@
|
| |
Assert that issue will be closed if fedora-review tag is missing on bugzilla.
|
| |
"""
|
| |
issue_id = 99
|
| |
- issue_body = "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577 ."
|
| |
+ issue_body = (
|
| |
+ "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577 ."
|
| |
+ )
|
| |
close_issue_msg = (
|
| |
"Tag fedora-review is missing on bugzilla, get it and reopen ticket later."
|
| |
)
|
| |
@@ -794,8 +803,10 @@
|
| |
Assert that issue will be closed if fedora-review tag has wrong status.
|
| |
"""
|
| |
issue_id = 99
|
| |
- issue_body = "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577 " \
|
| |
- "something"
|
| |
+ issue_body = (
|
| |
+ "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577 "
|
| |
+ "something"
|
| |
+ )
|
| |
close_issue_msg = (
|
| |
"Bug tag '{0}' don't have required status '{1}', "
|
| |
"but have '{2}' instead.\n"
|
| |
@@ -823,7 +834,9 @@
|
| |
Assert that verify bugzilla process correctly.
|
| |
"""
|
| |
issue_id = 99
|
| |
- issue_body = "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577"
|
| |
+ issue_body = (
|
| |
+ "Something https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2195577"
|
| |
+ )
|
| |
|
| |
bug = Mock()
|
| |
bug.get_flags.return_value = [{"status": "+"}]
|
| |
@@ -1054,8 +1067,8 @@
|
| |
]
|
| |
|
| |
assert (
|
| |
- self.toddler._is_need_to_unblock_tags_on_koji(tags_to_unblock, repo)
|
| |
- is False
|
| |
+ self.toddler._is_need_to_unblock_tags_on_koji(tags_to_unblock, repo)
|
| |
+ is False
|
| |
)
|
| |
|
| |
|
| |
@@ -1116,9 +1129,13 @@
|
| |
"""
|
| |
self.toddler = pdc_unretire_packages.PDCUnretirePackages()
|
| |
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages"
|
| |
- "._get_proper_eol_for_branches")
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages._namespace_to_pdc")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages"
|
| |
+ "._get_proper_eol_for_branches"
|
| |
+ )
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages._namespace_to_pdc"
|
| |
+ )
|
| |
@patch("toddlers.utils.pdc.adjust_eol")
|
| |
def test_adjust_eol_pdc(self, adjust_eol_mock, namespace_to_pdc_mock, get_eol_mock):
|
| |
"""
|
| |
@@ -1147,12 +1164,17 @@
|
| |
eol=eol,
|
| |
)
|
| |
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages"
|
| |
- "._get_proper_eol_for_branches")
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages._namespace_to_pdc")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages"
|
| |
+ "._get_proper_eol_for_branches"
|
| |
+ )
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages._namespace_to_pdc"
|
| |
+ )
|
| |
@patch("toddlers.utils.pdc.adjust_eol")
|
| |
- def test_adjust_eol_pdc_few_branches(self, adjust_eol_mock, namespace_to_pdc_mock,
|
| |
- get_eol_mock):
|
| |
+ def test_adjust_eol_pdc_few_branches(
|
| |
+ self, adjust_eol_mock, namespace_to_pdc_mock, get_eol_mock
|
| |
+ ):
|
| |
"""
|
| |
Assert that adjust_eol_pdc process correctly with few branches.
|
| |
"""
|
| |
@@ -1242,8 +1264,10 @@
|
| |
"""
|
| |
self.toddler = pdc_unretire_packages.PDCUnretirePackages()
|
| |
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages."
|
| |
- "_get_last_fedora_version_branch_name")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages."
|
| |
+ "_get_last_fedora_version_branch_name"
|
| |
+ )
|
| |
@patch("requests.get")
|
| |
def test_get_proper_eol_for_branches(self, get_request_mock, get_last_branch_mock):
|
| |
"""
|
| |
@@ -1259,19 +1283,38 @@
|
| |
response.json.return_value = {
|
| |
"total": 2,
|
| |
"releases": [
|
| |
- {"dist_tag": "f39", "state": "pending", "branch": "rawhide", "eol": None},
|
| |
- {"dist_tag": "f37", "state": "pending", "branch": "rawhide", "eol": "2023-01-01"},
|
| |
- {"dist_tag": "f38", "state": "pending", "branch": "rawhide", "eol": "2023-01-01"},
|
| |
+ {
|
| |
+ "dist_tag": "f39",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": None,
|
| |
+ },
|
| |
+ {
|
| |
+ "dist_tag": "f37",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": "2023-01-01",
|
| |
+ },
|
| |
+ {
|
| |
+ "dist_tag": "f38",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": "2023-01-01",
|
| |
+ },
|
| |
],
|
| |
}
|
| |
get_request_mock.return_value = response
|
| |
|
| |
assert self.toddler._get_proper_eol_for_branches(tags_to_unblock) == result
|
| |
|
| |
- @patch("toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages."
|
| |
- "_get_last_fedora_version_branch_name")
|
| |
+ @patch(
|
| |
+ "toddlers.plugins.pdc_unretire_packages.PDCUnretirePackages."
|
| |
+ "_get_last_fedora_version_branch_name"
|
| |
+ )
|
| |
@patch("requests.get")
|
| |
- def test_get_proper_eol_for_branches_few_branches(self, get_request_mock, get_last_branch_mock):
|
| |
+ def test_get_proper_eol_for_branches_few_branches(
|
| |
+ self, get_request_mock, get_last_branch_mock
|
| |
+ ):
|
| |
"""
|
| |
Assert that get eol process correctly for few branches
|
| |
"""
|
| |
@@ -1287,9 +1330,24 @@
|
| |
response.json.return_value = {
|
| |
"total": 2,
|
| |
"releases": [
|
| |
- {"dist_tag": "f37", "state": "pending", "branch": "rawhide", "eol": "2023-01-01"},
|
| |
- {"dist_tag": "f38", "state": "pending", "branch": "rawhide", "eol": "2023-01-02"},
|
| |
- {"dist_tag": "f39", "state": "pending", "branch": "rawhide", "eol": None},
|
| |
+ {
|
| |
+ "dist_tag": "f37",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": "2023-01-01",
|
| |
+ },
|
| |
+ {
|
| |
+ "dist_tag": "f38",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": "2023-01-02",
|
| |
+ },
|
| |
+ {
|
| |
+ "dist_tag": "f39",
|
| |
+ "state": "pending",
|
| |
+ "branch": "rawhide",
|
| |
+ "eol": None,
|
| |
+ },
|
| |
],
|
| |
}
|
| |
get_request_mock.return_value = response
|
| |