#97 Update for newer RPM
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/compose-utils fix-decoding-with-new-rawhide  into  master

file modified
+1
@@ -9,3 +9,4 @@ 

  .coverage

  htmlcov/

  tests/repo

+ .tox

file modified
+4 -14
@@ -37,16 +37,6 @@ 

      return '{0:.{1}f} {2}'.format(size, prec, chosen)

  

  

- def to_utf8(text):

-     encodings = ["ascii", "utf8", "latin1", "latin2"]

-     for encoding in encodings:

-         try:

-             return text.decode(encoding)

-         except UnicodeDecodeError:

-             pass

-     return text.decode("ascii", "ignore")

- 

- 

  clogs = {}

  

  
@@ -61,7 +51,7 @@ 

          ts = kwargs.pop("ts", None)

          header = kobo.rpmlib.get_rpm_header(file_path, ts=ts)

  

-         self.summary = kobo.rpmlib.get_header_field(header, "summary").decode('utf-8')

+         self.summary = kobo.rpmlib.get_header_field(header, "summary")

  

          if self.sourcerpm:

              key = self.sourcerpm
@@ -106,10 +96,10 @@ 

          result = []

          try:

              old_time = old_changelog[0].time

-             old_nvr = LooseVersion(to_utf8(old_changelog[0].name).rsplit(None, 1)[-1])

+             old_nvr = LooseVersion(old_changelog[0].name.rsplit(None, 1)[-1])

              while new_changelog:

                  entry = new_changelog.pop(0)

-                 new_nvr = LooseVersion(to_utf8(entry.name).rsplit(None, 1)[-1])

+                 new_nvr = LooseVersion(entry.name.rsplit(None, 1)[-1])

                  if entry.time < old_time or (

                      entry.time == old_time and new_nvr <= old_nvr

                  ):
@@ -375,7 +365,7 @@ 

  

              data["changelog"] = []

              for i in get_changelog_diff_from_headers(old_package, new_package, max_logs):

-                 data["changelog"].append("* %s %s\n%s" % (i.ctime, to_utf8(i.name), to_utf8(i.text)))

+                 data["changelog"].append("* %s %s\n%s" % (i.ctime, i.name, i.text))

  

              # TODO: comps, system release

              # if rpm.versionCompare(old_package, new_package.header) == -1:

file modified
+10 -10
@@ -28,7 +28,7 @@ 

      'old_rpms': ['Dummy-firefox'],

      'common_rpms': ['Dummy-firefox'],

      'rpms': ['Dummy-firefox'],

-     'changelog': [u'* Tue Mar 15 2016 Lubomír Sedlář <lubomir.sedlar@gmail.com> - 1:0.1.0-1\n- new version'],

+     'changelog': ['* Tue Mar 15 2016 Lubomír Sedlář <lubomir.sedlar@gmail.com> - 1:0.1.0-1\n- new version'],

      'added_rpms': [],

      'dropped_rpms': [],

      'nvr': 'Dummy-firefox-1:0.1.0-1',
@@ -60,7 +60,7 @@ 

      'old_rpms': ['cloud-init'],

      'common_rpms': ['cloud-init'],

      'rpms': ['cloud-init'],

-     'changelog': [u'* Tue Sep 05 2017 Lubomír Sedlář <lsedlar@redhat.com> - 0.7.9-9.module_f8c7dcdc\n- First release'],

+     'changelog': ['* Tue Sep 05 2017 Lubomír Sedlář <lsedlar@redhat.com> - 0.7.9-9.module_f8c7dcdc\n- First release'],

      'added_rpms': [],

      'dropped_rpms': [],

      'nvr': 'cloud-init-0.7.9-9.module_f8c7dcdc',
@@ -227,26 +227,26 @@ 

  

  class TestCompareChangelogs(unittest.TestCase):

      def test_select_new(self):

-         c1 = ChangelogEntry(b'John Doe <jdoe@example.com> 1.0-1', 1000000, 'change 1')

-         c2 = ChangelogEntry(b'John Doe <jdoe@example.com> 1.1-1', 2000000, 'change 2')

+         c1 = ChangelogEntry('John Doe <jdoe@example.com> 1.0-1', 1000000, 'change 1')

+         c2 = ChangelogEntry('John Doe <jdoe@example.com> 1.1-1', 2000000, 'change 2')

          old = mock.Mock(changelogs=[c1])

          new = mock.Mock(changelogs=[c2, c1])

          clog = get_changelog_diff_from_headers(old, new)

          self.assertEqual(clog, [c2])

  

      def test_select_with_same_date(self):

-         c1 = ChangelogEntry(b'John Doe <jdoe@example.com> 1.0-1', 1000000, 'change 1')

-         c2 = ChangelogEntry(b'John Doe <jdoe@example.com> 1.1-1', 1000000, 'change 2')

+         c1 = ChangelogEntry('John Doe <jdoe@example.com> 1.0-1', 1000000, 'change 1')

+         c2 = ChangelogEntry('John Doe <jdoe@example.com> 1.1-1', 1000000, 'change 2')

          old = mock.Mock(changelogs=[c1])

          new = mock.Mock(changelogs=[c2, c1])

          clog = get_changelog_diff_from_headers(old, new)

          self.assertEqual(clog, [c2])

  

      def test_no_subset(self):

-         c1 = ChangelogEntry(b'John Doe <jdoe@example.com> 0:2.0-1', 1000000, 'change 1')

-         c2 = ChangelogEntry(b'John Doe <jdoe@example.com> 1:1.1-1', 1000000, 'change 2')

-         c3 = ChangelogEntry(b'John Doe <jdoe@example.com> 1:1.2-1', 1000000, 'change 3')

-         c4 = ChangelogEntry(b'John Doe <jdoe@example.com> 1:1.3-1', 1000000, 'change 4')

+         c1 = ChangelogEntry('John Doe <jdoe@example.com> 0:2.0-1', 1000000, 'change 1')

+         c2 = ChangelogEntry('John Doe <jdoe@example.com> 1:1.1-1', 1000000, 'change 2')

+         c3 = ChangelogEntry('John Doe <jdoe@example.com> 1:1.2-1', 1000000, 'change 3')

+         c4 = ChangelogEntry('John Doe <jdoe@example.com> 1:1.3-1', 1000000, 'change 4')

          old = mock.Mock(changelogs=[c3, c1])

          new = mock.Mock(changelogs=[c4, c2, c1])

          clog = get_changelog_diff_from_headers(old, new)

file modified
+6 -3
@@ -1,14 +1,17 @@ 

  [tox]

- envlist=py27,py35,py36

+ envlist=py26,py27,py35,py36,py37,py38

+ skip_missing_interpreters = true

+ minversion=3.12.0

  

  [testenv]

  deps=

    nose

    mock

-   freezegun

+   py26: freezegun<0.3.11

+   !py26: freezegun

    unittest2

    koji

-   kobo

+   kobo>=0.10.0

  commands=

    nosetests

  

python < 4.14.2 returned bytes, but that is now changed to return decoded strings.

Once Kobo is updated to work with newer RPM, these changes are still needed to get the test suite passing.

The tests are expected to fail until the kobo patch is merged and released.

Relates: https://bugzilla.redhat.com/show_bug.cgi?id=1713107
Relates: https://github.com/release-engineering/kobo/pull/115

rebased onto d51cf6078963d6373f7a9704fe2fbc6938a929f5

4 years ago

rebased onto 1519ead6393c894fd4c06a2117cecf8b61d56f8c

4 years ago

rebased onto 2f89ca36f23d46ef16eb4e4ca2da05b19019737e

4 years ago

rebased onto 86c951c

4 years ago

Pull-Request has been merged by lsedlar

4 years ago