Exemplo n.º 1
0
 def test_generate_webapp_fn_partial_non_ascii(self):
     f = File()
     f.version = Version(version='0.1.7')
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(app_slug=u'myapp フォクすけ  といっしょ',
                             type=amo.ADDON_WEBAPP)
     eq_(f.generate_filename(), 'myapp-0.1.7.webapp')
Exemplo n.º 2
0
    def create_blocklisted_version(self):
        """
        Creates a new version who's file is the blocklisted app found in /media
        and sets status to STATUS_BLOCKLISTED.

        """
        blocklisted_path = os.path.join(settings.MEDIA_ROOT, 'packaged-apps',
                                        'blocklisted.zip')
        last_version = self.current_version.version
        v = Version.objects.create(
            addon=self, version='blocklisted-%s' % last_version)
        f = File(version=v, status=amo.STATUS_BLOCKED,
                 platform=Platform.objects.get(id=amo.PLATFORM_ALL.id))
        f.filename = f.generate_filename()
        copy_stored_file(blocklisted_path, f.file_path)
        log.info(u'[Webapp:%s] Copied blocklisted app from %s to %s' % (
            self.id, blocklisted_path, f.file_path))
        f.size = storage.size(f.file_path)
        f.hash = f.generate_hash(f.file_path)
        f.save()
        f.inject_ids()
        self.sign_if_packaged(v.pk)
        self.status = amo.STATUS_BLOCKED
        self._current_version = v
        self.save()
Exemplo n.º 3
0
 def test_generate_filename_ja(self):
     f = File()
     f.version = Version(version='0.1.7')
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(name=u' フォクすけといっしょ')
     eq_(f.generate_filename(),
         u'\u30d5\u30a9\u30af\u3059\u3051\u3068\u3044\u3063\u3057\u3087'
         '-0.1.7-fx.xpi')
Exemplo n.º 4
0
    def _save_file(self, version):
        data = self.cleaned_data
        xpi = data["xpi"]
        hash = hashlib.sha256()

        f = File(version=version, platform_id=amo.PLATFORM_DICT[data["platform"]].id, size=xpi.size)

        filename = f.generate_filename()
        path = os.path.join(user_media_path("addons"), str(version.addon.id))
        with storage.open(os.path.join(path, filename), "wb") as destination:
            for chunk in xpi.chunks():
                hash.update(chunk)
                destination.write(chunk)

        f.hash = "sha256:%s" % hash.hexdigest()
        f.save()
        return f
Exemplo n.º 5
0
    def _save_file(self, version):
        data = self.cleaned_data
        xpi = data['xpi']
        hash = hashlib.sha256()

        f = File(version=version,
                 platform_id=amo.PLATFORM_DICT[data['platform']].id,
                 size=xpi.size)

        filename = f.generate_filename()
        path = os.path.join(settings.ADDONS_PATH, str(version.addon.id))
        with storage.open(os.path.join(path, filename), 'wb') as destination:
            for chunk in xpi.chunks():
                hash.update(chunk)
                destination.write(chunk)

        f.hash = 'sha256:%s' % hash.hexdigest()
        f.save()
        return f
Exemplo n.º 6
0
 def test_generate_filename_ja(self):
     f = File()
     f.version = Version(version='0.1.7')
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(name=u' フォクすけ  といっしょ')
     eq_(f.generate_filename(), 'addon-0.1.7-fx.xpi')
Exemplo n.º 7
0
 def test_generate_filename_ja(self):
     f = File()
     f.version = Version(version="0.1.7")
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(name=u" フォクすけ  といっしょ")
     eq_(f.generate_filename(), "addon-0.1.7-fx.xpi")
Exemplo n.º 8
0
 def test_generate_webapp_fn_non_ascii(self):
     f = File()
     f.version = Version(version="0.1.7")
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(app_slug=u" フォクすけ  といっしょ", type=amo.ADDON_WEBAPP)
     eq_(f.generate_filename(), "app-0.1.7.webapp")
Exemplo n.º 9
0
 def test_generate_filename_ja(self):
     f = File()
     f.version = Version(version='0.1.7')
     f.version.addon = Addon(name=u' フォクすけ  といっしょ')
     eq_(f.generate_filename(), 'none-0.1.7.webapp')
Exemplo n.º 10
0
 def test_generate_filename_ja(self):
     f = File()
     f.version = Version(version='0.1.7')
     f.version.compatible_apps = (amo.FIREFOX,)
     f.version.addon = Addon(name=u' フォクすけ  といっしょ')
     eq_(f.generate_filename(), 'addon-0.1.7-fx.xpi')