Merge ~pappacena/launchpad:upload-parse-error-msg into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: d069efd76279294259f177923c9e54d03921b117
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:upload-parse-error-msg
Merge into: launchpad:master
Diff against target: 58 lines (+24/-4)
2 files modified
lib/lp/archiveuploader/nascentuploadfile.py (+3/-3)
lib/lp/archiveuploader/tests/test_nascentuploadfile.py (+21/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+386290@code.launchpad.net

Commit message

Adding more information to DebFile parsing when uploading deb package

To post a comment you must log in.
d069efd... by Thiago F. Pappacena

Removing warning

Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/archiveuploader/nascentuploadfile.py b/lib/lp/archiveuploader/nascentuploadfile.py
index d69f25d..52b8b58 100644
--- a/lib/lp/archiveuploader/nascentuploadfile.py
+++ b/lib/lp/archiveuploader/nascentuploadfile.py
@@ -563,10 +563,10 @@ class BaseBinaryUploadFile(PackageUploadFile):
563 deb_file = apt_inst.DebFile(self.filepath)563 deb_file = apt_inst.DebFile(self.filepath)
564 control_file = deb_file.control.extractdata("control")564 control_file = deb_file.control.extractdata("control")
565 control_lines = apt_pkg.TagSection(control_file, bytes=True)565 control_lines = apt_pkg.TagSection(control_file, bytes=True)
566 except Exception:566 except Exception as e:
567 yield UploadError(567 yield UploadError(
568 "%s: extracting control file raised %s, giving up."568 "%s: extracting control file raised %s: %s. giving up."
569 % (self.filename, sys.exc_type))569 % (self.filename, sys.exc_type, e))
570 return570 return
571571
572 for mandatory_field in self.mandatory_fields:572 for mandatory_field in self.mandatory_fields:
diff --git a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
index ff63636..1ad7a81 100644
--- a/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
+++ b/lib/lp/archiveuploader/tests/test_nascentuploadfile.py
@@ -41,7 +41,10 @@ from lp.archiveuploader.nascentuploadfile import (
41from lp.archiveuploader.tests import AbsolutelyAnythingGoesUploadPolicy41from lp.archiveuploader.tests import AbsolutelyAnythingGoesUploadPolicy
42from lp.buildmaster.enums import BuildStatus42from lp.buildmaster.enums import BuildStatus
43from lp.registry.interfaces.pocket import PackagePublishingPocket43from lp.registry.interfaces.pocket import PackagePublishingPocket
44from lp.services.compat import lzma44from lp.services.compat import (
45 lzma,
46 mock,
47 )
45from lp.services.log.logger import BufferLogger48from lp.services.log.logger import BufferLogger
46from lp.services.osutils import write_file49from lp.services.osutils import write_file
47from lp.soyuz.enums import (50from lp.soyuz.enums import (
@@ -517,6 +520,23 @@ class DebBinaryUploadFileTests(PackageUploadFileTestCase):
517 uploadfile.extractAndParseControl()520 uploadfile.extractAndParseControl()
518 self.assertEqual([], list(uploadfile.verifyFormat()))521 self.assertEqual([], list(uploadfile.verifyFormat()))
519522
523 @mock.patch("lp.archiveuploader.nascentuploadfile.apt_inst")
524 def test_extractAndParseControl_UploadError_message(self, m_apt_inst):
525 # extractAndParseControl should yield a reasonable error message if
526 # apt_inst.DebFile raises an exception
527 m_apt_inst.DebFile.side_effect = KeyError("banana not found")
528 uploadfile = self.createDebBinaryUploadFile(
529 "empty_0.1_all.deb", "main/admin", "extra", "empty", "0.1", None,
530 members=[])
531 errors = list(uploadfile.extractAndParseControl())
532 self.assertEqual(1, len(errors))
533 error = errors[0]
534 self.assertIsInstance(error, UploadError)
535 self.assertEqual(
536 "empty_0.1_all.deb: extracting control file raised "
537 "<type 'exceptions.KeyError'>: u'banana not found'."
538 " giving up.", str(error))
539
520 def test_verifyDebTimestamp_SystemError(self):540 def test_verifyDebTimestamp_SystemError(self):
521 # verifyDebTimestamp produces a reasonable error if we provoke a541 # verifyDebTimestamp produces a reasonable error if we provoke a
522 # SystemError from apt_inst.DebFile.542 # SystemError from apt_inst.DebFile.