public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/fedpkg] 1.48-1: Patch: Fix unittest for bodhi based on its version
Date: Mon, 10 Aug 2026 21:45:53 GMT	[thread overview]
Message-ID: <178639835379.1.5995713204389709936.rpms-fedpkg-aaa434fc637f@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/fedpkg
            Branch : 1.48-1
            Commit : aaa434fc637f9bec434492aaddb4614970fc120b
            Author : Ondřej Nosek <onosek@redhat.com>
            Date   : 2020-05-18T14:02:21+00:00
            Stats  : +52/-194 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/fedpkg/c/aaa434fc637f9bec434492aaddb4614970fc120b?branch=1.48-1

            Log:
            Patch: Fix unittest for bodhi based on its version

Signed-off-by: Ondřej Nosek <onosek@redhat.com>

---
diff --git a/0001-fedpkg-request-use-pdc-active-releases.patch b/0001-fedpkg-request-use-pdc-active-releases.patch
deleted file mode 100644
index 39b6efb..0000000
--- a/0001-fedpkg-request-use-pdc-active-releases.patch
+++ /dev/null
@@ -1,189 +0,0 @@
-From 00aed529cf22796fdae0d23f844221df640cc7c2 Mon Sep 17 00:00:00 2001
-From: mprahl <mprahl@redhat.com>
-Date: Feb 23 2018 03:01:35 +0000
-Subject: Use PDC instead of Bodhi to get the active release branches
-
-
-Fixes #187
-
-Signed-off-by: mprahl <mprahl@redhat.com>
-
----
-
-diff --git a/fedpkg/cli.py b/fedpkg/cli.py
-index a203b91..e8ff6be 100644
---- a/fedpkg/cli.py
-+++ b/fedpkg/cli.py
-@@ -462,7 +462,7 @@ suggest_reboot=False
-                 raise rpkgError('You must specify a branch if you are not in '
-                                 'a git repository')
- 
--        bodhi_url = config.get('{0}.bodhi'.format(name), 'url')
-+        pdc_url = config.get('{0}.pdc'.format(name), 'url')
-         if branch:
-             if is_epel(branch):
-                 assert_valid_epel_package(module_name, branch)
-@@ -474,7 +474,7 @@ suggest_reboot=False
-                         'Only characters, numbers, periods, dashes, '
-                         'underscores, and pluses are allowed in module branch '
-                         'names')
--            release_branches = get_release_branches(bodhi_url)
-+            release_branches = get_release_branches(pdc_url)
-             if branch in release_branches:
-                 if service_levels:
-                     raise rpkgError(
-@@ -489,14 +489,13 @@ suggest_reboot=False
- 
-         # If service levels were provided, verify them
-         if service_levels:
--            pdc_url = config.get('{0}.pdc'.format(name), 'url')
-             sl_dict = sl_list_to_dict(service_levels)
-             verify_sls(pdc_url, sl_dict)
- 
-         pagure_url = config.get('{0}.pagure'.format(name), 'url')
-         pagure_token = get_pagure_token(config, name)
-         if all_releases:
--            release_branches = get_release_branches(bodhi_url)
-+            release_branches = get_release_branches(pdc_url)
-             branches = [b for b in release_branches
-                         if re.match(r'^(f\d+)$', b)]
-         else:
-diff --git a/fedpkg/utils.py b/fedpkg/utils.py
-index d241308..b3d704c 100644
---- a/fedpkg/utils.py
-+++ b/fedpkg/utils.py
-@@ -18,7 +18,6 @@ from six.moves.urllib.parse import urlencode
- from six.moves.configparser import NoSectionError, NoOptionError
- import requests
- from requests.exceptions import ConnectionError
--from fedora.client.bodhi import Bodhi2Client
- from pyrpkg import rpkgError
- 
- 
-@@ -97,26 +96,55 @@ def new_pagure_issue(url, token, title, body):
-         url.rstrip('/'), rv.json()['issue']['id'])
- 
- 
--def get_release_branches(bodhi_url):
-+def get_release_branches(url):
-     """
--    Get the active Fedora release branches from Bodhi
--    :param bodhi_url: a string of the URL to Bodhi
-+    Get the active Fedora release branches from PDC
-+    :param url: a string of the URL to PDC
-     :return: a set containing the active Fedora release branches
-     """
--    bodhi = Bodhi2Client(bodhi_url)
-     branches = set()
--    page = 1
-+    api_url = '{0}/rest_api/v1/product-versions/'.format(url.rstrip('/'))
-+    query_args = {
-+        'fields': ['short', 'version'],
-+        'active': True
-+    }
-     while True:
--        rv = bodhi.send_request('releases', auth=False, params={'page': page})
--        for release in rv['releases']:
--            if release['state'] == 'current':
--                branches.add(release['branch'])
--        if page < rv['pages']:
--            page += 1
--        else:
--            break
-+        try:
-+            rv = requests.get(api_url, params=query_args, timeout=60)
-+        except ConnectionError as error:
-+            error_msg = ('The connection to PDC failed while trying to get '
-+                         'the active release branches. The error was: {0}'
-+                         .format(str(error)))
-+            raise rpkgError(error_msg)
- 
--    return branches
-+        if not rv.ok:
-+            base_error_msg = ('The following error occurred while trying to '
-+                              'get the active release branches in PDC: {0}')
-+            raise rpkgError(base_error_msg.format(rv.text))
-+
-+        rv_json = rv.json()
-+        for product_version in rv_json['results']:
-+            # If the version is not a digit we can ignore it (e.g. rawhide)
-+            if not product_version['version'].isdigit():
-+                continue
-+
-+            if product_version['short'] == 'epel':
-+                prefix = 'epel'
-+                if product_version['version'] == '6':
-+                    prefix = 'el'
-+                branches.add('{0}{1}'.format(
-+                    prefix, product_version['version']))
-+            elif product_version['short'] == 'fedora':
-+                branches.add('f{0}'.format(product_version['version']))
-+
-+        if rv_json['next']:
-+            # Clear the query_args because they are baked into the "next" URL
-+            query_args = {}
-+            api_url = rv_json['next']
-+        else:
-+            # We've gone through every page, so we can return the found
-+            # branches
-+            return branches
- 
- 
- def sl_list_to_dict(sls):
-diff --git a/test/test_utils.py b/test/test_utils.py
-index cff22bd..7ca395f 100644
---- a/test/test_utils.py
-+++ b/test/test_utils.py
-@@ -115,29 +115,29 @@ class TestUtils(CliTestCase):
-                 assert str(e) == ('The SL "{0}" must expire on June 1st or '
-                                   'December 1st'.format(eol))
- 
--    @patch('fedpkg.utils.Bodhi2Client')
--    def test_get_release_branches(self, mock_bodhi):
-+    @patch('requests.get')
-+    def test_get_release_branches(self, mock_request_get):
-         """Test that get_release_branches returns all the active Fedora release
-         branches.
-         """
--        mock_bodhi_client = Mock()
--        mock_bodhi_client.send_request.return_value = {
--            u'page': 1,
--            u'pages': 1,
--            u'releases': [
--                {'state': 'current', 'branch': 'el6'},
--                {'state': 'archived', 'branch': 'f24'},
--                {'state': 'current', 'branch': 'epel7'},
--                {'state': 'current', 'branch': 'f25'},
--                {'state': 'archived', 'branch': 'el5'},
--                {'state': 'archived', 'branch': 'f23'},
--                {'state': 'current', 'branch': 'f26'},
--                {'state': 'pending', 'branch': 'f27m'},
--                {'state': 'current', 'branch': 'f27'}
--            ],
--            u'rows_per_page': 20,
--            u'total': 11}
--        mock_bodhi.return_value = mock_bodhi_client
--        expected = set(['el6', 'epel7', 'f25', 'f26', 'f27'])
--        actual = utils.get_release_branches('http://bodhi.local')
-+        mock_rv = Mock()
-+        mock_rv.ok = True
-+        # This abbreviated data returned from the product-versions PDC API
-+        mock_rv.json.return_value = {
-+            'count': 7,
-+            'next': None,
-+            'previous': None,
-+            'results': [
-+                {'short': 'epel', 'version': '6'},
-+                {'short': 'epel', 'version': '7'},
-+                {'short': 'fedora', 'version': '25'},
-+                {'short': 'fedora', 'version': '26'},
-+                {'short': 'fedora', 'version': '27'},
-+                {'short': 'fedora', 'version': '28'},
-+                {'short': 'fedora', 'version': 'rawhide'}
-+            ]
-+        }
-+        mock_request_get.return_value = mock_rv
-+        expected = set(['el6', 'epel7', 'f25', 'f26', 'f27', 'f28'])
-+        actual = utils.get_release_branches('http://pdc.local')
-         self.assertEqual(expected, actual)
-

diff --git a/0011-Fix-unittest-for-bodhi-based-on-its-version.patch b/0011-Fix-unittest-for-bodhi-based-on-its-version.patch
new file mode 100644
index 0000000..3c36e82
--- /dev/null
+++ b/0011-Fix-unittest-for-bodhi-based-on-its-version.patch
@@ -0,0 +1,43 @@
+From e33087c78c20aa46768328181973bfcf6a5c8d4e Mon Sep 17 00:00:00 2001
+From: Ondrej Nosek <onosek@redhat.com>
+Date: Mon, 18 May 2020 14:17:19 +0200
+Subject: [PATCH] Fix unittest for bodhi based on its version
+
+Signed-off-by: Ondrej Nosek <onosek@redhat.com>
+---
+ test/test_cli.py | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/test/test_cli.py b/test/test_cli.py
+index 0376ded..1258810 100644
+--- a/test/test_cli.py
++++ b/test/test_cli.py
+@@ -128,6 +128,16 @@ class TestUpdate(CliTestCase):
+         with io.open(clog_file, 'w', encoding='utf-8') as f:
+             f.write(os.linesep.join(self.fake_clog))
+ 
++        # Get 'bodhi_client' version. Particular versions have differences
++        # across distributions.
++        self.bodhi_version = None
++        try:
++            version_object = pkg_resources.get_distribution('bodhi_client')
++            if version_object.has_version():
++                self.bodhi_version = int(version_object.version.split('.')[0])
++        except pkg_resources.DistributionNotFound:
++            pass
++
+     def tearDown(self):
+         if os.path.exists('bodhi.template'):
+             os.unlink('bodhi.template')
+@@ -195,6 +205,8 @@ class TestUpdate(CliTestCase):
+             expected_data['notes'] = notes
+         else:
+             expected_data['notes'] = self.fake_clog[0]
++        if self.bodhi_version <= 4:
++            del expected_data["display_name"]
+ 
+         with patch('os.unlink') as unlink:
+             cli.update()
+-- 
+2.21.3
+

diff --git a/fedpkg.spec b/fedpkg.spec
index 6cf42d9..9154dc7 100644
--- a/fedpkg.spec
+++ b/fedpkg.spec
@@ -5,7 +5,7 @@
 
 Name:           fedpkg
 Version:        1.38
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Fedora utility for working with dist-git
 
 License:        GPLv2+
@@ -18,6 +18,7 @@ Patch2:         0007-Move-rpm-dependency-for-test-environment-only.patch
 Patch3:         0008-Repair-test-of-retire-command-after-rpkg-update.patch
 Patch4:         0009-Body-changes-for-requesting-new-test-repo.patch
 Patch5:         0010-Check-missing-config-options-more-reliably.patch
+Patch6:         0011-Fix-unittest-for-bodhi-based-on-its-version.patch
 
 # fedpkg command switched to python3 on Fedora 29 and RHEL > 7:
 %if 0%{?fedora} || 0%{?rhel} > 7
@@ -40,7 +41,7 @@ Requires:       redhat-rpm-config
 
 BuildRequires:  python2-devel
 # We br these things for man page generation due to imports
-BuildRequires:  python2-rpkg >= 1.59-5
+BuildRequires:  python2-rpkg >= 1.60-1
 BuildRequires:  python2-distro
 # This until fedora-cert gets fixed
 BuildRequires:  python2-fedora
@@ -73,7 +74,7 @@ BuildRequires:  python2-bugzilla
 Requires:       python2-bugzilla
 %endif
 
-Requires:       python2-rpkg >= 1.59-5
+Requires:       python2-rpkg >= 1.60-1
 Requires:       python2-distro
 Requires:       python2-fedora
 Requires:       python2-openidc-client >= 0.6.0
@@ -84,7 +85,7 @@ Requires:       python2-openidc-client >= 0.6.0
 %global __python %{__python3}
 
 BuildRequires:  python3-devel
-BuildRequires:  python3-rpkg >= 1.59-5
+BuildRequires:  python3-rpkg >= 1.60-1
 BuildRequires:  python3-distro
 # This until fedora-cert gets fixed
 BuildRequires:  python3-fedora
@@ -98,7 +99,7 @@ BuildRequires:  python3-bodhi-client
 
 
 Requires:       python3-bugzilla
-Requires:       python3-rpkg >= 1.59-5
+Requires:       python3-rpkg >= 1.60-1
 Requires:       python3-distro
 Requires:       python3-fedora
 Requires:       python3-openidc-client >= 0.6.0
@@ -168,6 +169,9 @@ nosetests
 
 
 %changelog
+* Mon May 18 2020 Ondřej Nosek <onosek@redhat.com> - 1.38-4
+- Patch: Fix unittest for bodhi based on its version
+
 * Mon Mar 30 2020 Ondřej Nosek <onosek@redhat.com> - 1.38-3
   Patches:
   - Repair test of "retire" command after rpkg update

                 reply	other threads:[~2026-08-10 21:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178639835379.1.5995713204389709936.rpms-fedpkg-aaa434fc637f@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox