Skip to content
This repository

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

Merged
merged 1 commit into from over 1 year ago

3 participants

kmaglione Christopher Van Rob Hudson
kmaglione

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

Christopher Van
Collaborator
cvan commented August 08, 2012

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):
807 810
         f = File.from_upload(upload, self.version, self.platform, data)
808 811
         eq_(f.strict_compatibility, True)
809 812
 
  813
+    def test_theme_extension(self):
  814
+        upload = self.upload('theme.jar')
  815
+        f = File.from_upload(upload, self.version, self.platform)
  816
+        eq_(f.filename.endswith('.xpi'), True)
  817
+
  818
+    def test_extension_extension(self):
  819
+        upload = self.upload('extension.xpi')
  820
+        f = File.from_upload(upload, self.version, self.platform)
  821
+        eq_(f.filename.endswith('.xpi'), True)
  822
+
  823
+    def test_langpack_extension(self):
  824
+        upload = self.upload('extension.xpi')
  825
+        f = File.from_upload(upload, self.version, self.platform)
  826
+        eq_(f.filename.endswith('.xpi'), True)
2
Rob Hudson Collaborator
robhudson added a note August 24, 2012

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

kmaglione
kmaglione added a note August 28, 2012
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.

Rob Hudson robhudson merged commit 2748eaa into from October 23, 2012
Rob Hudson robhudson closed this October 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 22, 2012
kmaglione Bug 701719: Give theme jars .xpi extension so that they have applicat…
…ion/x-xpinstall on download and on disk.
6febc57
This page is out of date. Refresh to see the latest.
5  apps/files/models.py
@@ -155,7 +155,10 @@ def from_upload(cls, upload, version, platform, parse_data={}):
155 155
         is_webapp = version.addon.is_webapp()
156 156
         f = cls(version=version, platform=platform)
157 157
         upload.path = amo.utils.smart_path(nfd_str(upload.path))
158  
-        f.filename = f.generate_filename(os.path.splitext(upload.path)[1])
  158
+        ext = os.path.splitext(upload.path)[1]
  159
+        if ext == '.jar':
  160
+            ext = '.xpi'
  161
+        f.filename = f.generate_filename(extension=ext or '.xpi')
159 162
         # Size in bytes.
160 163
         f.size = storage.size(upload.path)
161 164
         data = cls.get_jetpack_metadata(upload.path)
25  apps/files/tests/test_models.py
@@ -683,12 +683,15 @@ def setUp(self):
683 683
         self.version = Version.objects.create(addon=self.addon)
684 684
 
685 685
     def upload(self, name):
  686
+        if os.path.splitext(name)[-1] not in ['.xml', '.xpi', '.jar']:
  687
+            name = name + '.xpi'
  688
+
686 689
         v = json.dumps(dict(errors=0, warnings=1, notices=2, metadata={}))
687 690
         fname = nfd_str(self.xpi_path(name))
688 691
         if not storage.exists(fname):
689 692
             with storage.open(fname, 'w') as fs:
690 693
                 copyfileobj(open(fname), fs)
691  
-        d = dict(path=fname, name='%s.xpi' % name,
  694
+        d = dict(path=fname, name=name,
692 695
                  hash='sha256:%s' % name, validation=v)
693 696
         return FileUpload.objects.create(**d)
694 697
 
@@ -850,6 +853,26 @@ def test_strict_compat(self):
850 853
         f = File.from_upload(upload, self.version, self.platform, data)
851 854
         eq_(f.strict_compatibility, True)
852 855
 
  856
+    def test_theme_extension(self):
  857
+        upload = self.upload('theme.jar')
  858
+        f = File.from_upload(upload, self.version, self.platform)
  859
+        eq_(f.filename.endswith('.xpi'), True)
  860
+
  861
+    def test_extension_extension(self):
  862
+        upload = self.upload('extension.xpi')
  863
+        f = File.from_upload(upload, self.version, self.platform)
  864
+        eq_(f.filename.endswith('.xpi'), True)
  865
+
  866
+    def test_langpack_extension(self):
  867
+        upload = self.upload('langpack.xpi')
  868
+        f = File.from_upload(upload, self.version, self.platform)
  869
+        eq_(f.filename.endswith('.xpi'), True)
  870
+
  871
+    def test_search_extension(self):
  872
+        upload = self.upload('search.xml')
  873
+        f = File.from_upload(upload, self.version, self.platform)
  874
+        eq_(f.filename.endswith('.xml'), True)
  875
+
853 876
 
854 877
 class TestZip(amo.tests.TestCase, amo.tests.AMOPaths):
855 878
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.