Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 701719: Give theme jars .xpi extension so that they have application... #335

Merged
merged 1 commit into from

3 participants

@kmaglione

.../x-xpinstall on download and on disk.

@cvan
Owner

if you can update the tests, I can merge this in

@kmaglione

Updated with tests for search plugins, dictionaries, and langpacks.

apps/files/tests/test_models.py
@@ -807,6 +810,26 @@ def test_strict_compat(self):
f = File.from_upload(upload, self.version, self.platform, data)
eq_(f.strict_compatibility, True)
+ def test_theme_extension(self):
+ upload = self.upload('theme.jar')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
+
+ def test_extension_extension(self):
+ upload = self.upload('extension.xpi')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
+
+ def test_langpack_extension(self):
+ upload = self.upload('extension.xpi')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
@robhudson Collaborator

This one and the test above it are exactly the same?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kmaglione

I only just realized that this never got pushed when it came up on the editors list last night. Updated with the filename fix.

@robhudson robhudson merged commit 2748eaa into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 22, 2012
  1. @kmaglione

    Bug 701719: Give theme jars .xpi extension so that they have applicat…

    kmaglione authored
    …ion/x-xpinstall on download and on disk.
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 2 deletions.
  1. +4 −1 apps/files/models.py
  2. +24 −1 apps/files/tests/test_models.py
View
5 apps/files/models.py
@@ -155,7 +155,10 @@ def from_upload(cls, upload, version, platform, parse_data={}):
is_webapp = version.addon.is_webapp()
f = cls(version=version, platform=platform)
upload.path = amo.utils.smart_path(nfd_str(upload.path))
- f.filename = f.generate_filename(os.path.splitext(upload.path)[1])
+ ext = os.path.splitext(upload.path)[1]
+ if ext == '.jar':
+ ext = '.xpi'
+ f.filename = f.generate_filename(extension=ext or '.xpi')
# Size in bytes.
f.size = storage.size(upload.path)
data = cls.get_jetpack_metadata(upload.path)
View
25 apps/files/tests/test_models.py
@@ -683,12 +683,15 @@ def setUp(self):
self.version = Version.objects.create(addon=self.addon)
def upload(self, name):
+ if os.path.splitext(name)[-1] not in ['.xml', '.xpi', '.jar']:
+ name = name + '.xpi'
+
v = json.dumps(dict(errors=0, warnings=1, notices=2, metadata={}))
fname = nfd_str(self.xpi_path(name))
if not storage.exists(fname):
with storage.open(fname, 'w') as fs:
copyfileobj(open(fname), fs)
- d = dict(path=fname, name='%s.xpi' % name,
+ d = dict(path=fname, name=name,
hash='sha256:%s' % name, validation=v)
return FileUpload.objects.create(**d)
@@ -850,6 +853,26 @@ def test_strict_compat(self):
f = File.from_upload(upload, self.version, self.platform, data)
eq_(f.strict_compatibility, True)
+ def test_theme_extension(self):
+ upload = self.upload('theme.jar')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
+
+ def test_extension_extension(self):
+ upload = self.upload('extension.xpi')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
+
+ def test_langpack_extension(self):
+ upload = self.upload('langpack.xpi')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xpi'), True)
+
+ def test_search_extension(self):
+ upload = self.upload('search.xml')
+ f = File.from_upload(upload, self.version, self.platform)
+ eq_(f.filename.endswith('.xml'), True)
+
class TestZip(amo.tests.TestCase, amo.tests.AMOPaths):
Something went wrong with that request. Please try again.