Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Look to signed package to get file size (bug 834863)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Feb 1, 2013
1 parent 958ee1d commit 4f2e526
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
10 changes: 10 additions & 0 deletions mkt/submit/tests/test_views.py
Expand Up @@ -444,6 +444,7 @@ def post_addon(self, data=None):

def setup_files(self, filename='mozball.zip'):
# Make sure the source file is there.
# Original packaged file.
if not storage.exists(self.file.file_path):
try:
# We don't care if these dirs exist.
Expand All @@ -452,6 +453,15 @@ def setup_files(self, filename='mozball.zip'):
pass
shutil.copyfile(self.packaged_app_path(filename),
self.file.file_path)
# Signed packaged file.
if not storage.exists(self.file.signed_file_path):
try:
# We don't care if these dirs exist.
os.makedirs(os.path.dirname(self.file.signed_file_path))
except OSError:
pass
shutil.copyfile(self.packaged_app_path(filename),
self.file.signed_file_path)


class TestCreatePackagedApp(BasePackagedAppTest):
Expand Down
8 changes: 4 additions & 4 deletions mkt/webapps/models.py
Expand Up @@ -659,16 +659,16 @@ def get_cached_manifest(self, force=False):
if not version:
data = {}
else:
file = version.all_files[0]
file_obj = version.all_files[0]
manifest = self.get_manifest_json()
package_path = absolutify(
os.path.join(reverse('downloads.file', args=[file.id]),
file.filename))
os.path.join(reverse('downloads.file', args=[file_obj.id]),
file_obj.filename))

data = {
'name': manifest['name'],
'version': version.version,
'size': file.size,
'size': storage.size(file_obj.signed_file_path),
'release_notes': version.releasenotes,
'package_path': package_path,
}
Expand Down
9 changes: 5 additions & 4 deletions mkt/webapps/tests/test_models.py
Expand Up @@ -599,17 +599,18 @@ def test_cached_manifest_contents(self):
webapp = self.post_addon(
data={'packaged': True, 'free_platforms': 'free-firefoxos'})
version = webapp.current_version
file = version.all_files[0]
self.file = version.all_files[0]
self.setup_files()
manifest = self._get_manifest_json()

data = json.loads(webapp.get_cached_manifest())
eq_(data['name'], webapp.name)
eq_(data['version'], webapp.current_version.version)
eq_(data['size'], file.size)
eq_(data['size'], self.file.size)
eq_(data['release_notes'], version.releasenotes)
eq_(data['package_path'], absolutify(
os.path.join(reverse('downloads.file', args=[file.id]),
file.filename)))
os.path.join(reverse('downloads.file', args=[self.file.id]),
self.file.filename)))
eq_(data['developer'], manifest['developer'])
eq_(data['icons'], manifest['icons'])
eq_(data['locales'], manifest['locales'])
Expand Down

0 comments on commit 4f2e526

Please sign in to comment.