Merge lp:~james-w/pkgme-service/spot-desktop into lp:pkgme-service

Proposed by James Westby
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 156
Merged at revision: 156
Proposed branch: lp:~james-w/pkgme-service/spot-desktop
Merge into: lp:pkgme-service
Diff against target: 94 lines (+42/-2)
2 files modified
src/djpkgme/tasks.py (+12/-1)
src/djpkgme/tests/test_tasks.py (+30/-1)
To merge this branch: bzr merge lp:~james-w/pkgme-service/spot-desktop
Reviewer Review Type Date Requested Status
Ricardo Kirkner (community) Approve
Review via email: mp+210235@code.launchpad.net

Commit message

Check that the extracted package has a manifest file (required for click).

Description of the change

Hi,

This is quite a simple fix to get an informative review message if
someone submits a non-click .deb package to the click appstore.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/djpkgme/tasks.py'
2--- src/djpkgme/tasks.py 2014-01-29 18:34:03 +0000
3+++ src/djpkgme/tasks.py 2014-03-10 15:29:03 +0000
4@@ -291,10 +291,21 @@
5 explanation += indent(e.output, 4)
6 result['explanation'] = explanation
7 dest = None
8+ else:
9+ if not os.path.isfile(self.manifest_path(dest)):
10+ result['passed'] = False
11+ result['explanation'] = (
12+ 'The package has no manifest file '
13+ '(is it a desktop package?)'
14+ )
15+ dest = None
16 return dest, result
17
18+ def manifest_path(self, package):
19+ return os.path.join(package, 'DEBIAN/manifest')
20+
21 def get_package_manifest(self, package):
22- with open(os.path.join(package, 'DEBIAN/manifest')) as f:
23+ with open(self.manifest_path(package)) as f:
24 manifest_content = json.loads(f.read())
25 return manifest_content
26
27
28=== modified file 'src/djpkgme/tests/test_tasks.py'
29--- src/djpkgme/tests/test_tasks.py 2014-01-29 17:59:40 +0000
30+++ src/djpkgme/tests/test_tasks.py 2014-03-10 15:29:03 +0000
31@@ -664,6 +664,12 @@
32 tempdir_mock.__exit__ = mock.Mock(return_value=False)
33 return tempdir_mock
34
35+ def test_manifest_path(self):
36+ basepath = 'foo'
37+ job = ClickPackageReviewJob()
38+ self.assertEqual(os.path.join(basepath, 'DEBIAN', 'manifest'),
39+ job.manifest_path(basepath))
40+
41 @patch('djpkgme.tasks.download_file')
42 def test_download_package(self, mock_download_file):
43 mock_download_file.return_value = 'some/path'
44@@ -677,12 +683,14 @@
45 mock_download_file.assert_called_with(metadata['package_url'],
46 temp_dir)
47
48+ @patch('djpkgme.tasks.os.path.isfile')
49 @patch('djpkgme.tasks.subprocess.check_output')
50- def test_unpack_package(self, mock_call):
51+ def test_unpack_package(self, mock_call, mock_isfile):
52 job = ClickPackageReviewJob()
53 package_file = 'some/package'
54 temp_dir = 'temp/dir'
55 unpack_path = os.path.join(temp_dir, 'unpacked')
56+ mock_isfile.return_value = True
57 returned_path, check = job.unpack_package(package_file, temp_dir)
58 self.assertEqual(unpack_path, returned_path)
59 self.assertEqual(
60@@ -690,6 +698,9 @@
61 mock_call.assert_called_with(
62 ['dpkg-deb', '-R', package_file, unpack_path],
63 stderr=subprocess.STDOUT)
64+ mock_isfile.assert_called_with(
65+ os.path.join(unpack_path, 'DEBIAN', 'manifest')
66+ )
67
68 @patch('djpkgme.tasks.subprocess.check_output')
69 def test_unpack_package_fails(self, mock_call):
70@@ -712,6 +723,24 @@
71 ['dpkg-deb', '-R', package_file, unpack_path],
72 stderr=subprocess.STDOUT)
73
74+ @patch('djpkgme.tasks.os.path.isfile')
75+ @patch('djpkgme.tasks.subprocess.check_output')
76+ def test_unpack_package_no_manifest(self, mock_call, mock_isfile):
77+ job = ClickPackageReviewJob()
78+ package_file = 'some/package'
79+ temp_dir = 'temp/dir'
80+ unpack_path = os.path.join(temp_dir, 'unpacked')
81+ mock_isfile.return_value = False
82+ returned_path, check = job.unpack_package(package_file, temp_dir)
83+ self.assertEqual(None, returned_path)
84+ expected_result = dict(passed=False,
85+ description="Is a valid click package")
86+ expected_result['explanation'] = (
87+ "The package has no manifest file "
88+ "(is it a desktop package?)"
89+ )
90+ self.assertEqual(check, expected_result)
91+
92 def test_get_manifest(self):
93 job = ClickPackageJob()
94 package_name = 'some.package'

Subscribers

People subscribed via source and target branches