Ejemplo n.º 1
0
 def test_update_addon_from_xpi(self):
     path_xpi = os.path.join(
             settings.ROOT, 'apps/jetpack/tests/sample_addon.xpi')
     addon = create_package_from_xpi(path_xpi, self.author)
     addon = create_package_from_xpi(path_xpi, self.author)
     self.failUnless(addon)
     eq_(addon.revisions.count(), 2)
Ejemplo n.º 2
0
 def test_update_addon_from_xpi(self):
     path_xpi = os.path.join(settings.ROOT,
                             'apps/jetpack/tests/sample_addon.xpi')
     addon = create_package_from_xpi(path_xpi, self.author)
     addon = create_package_from_xpi(path_xpi, self.author)
     self.failUnless(addon)
     eq_(addon.revisions.count(), 2)
Ejemplo n.º 3
0
 def test_create_addon_from_xpi(self):
     path_xpi = os.path.join(
             settings.ROOT, 'apps/jetpack/tests/sample_addon.xpi')
     addon = create_package_from_xpi(path_xpi, self.author)
     self.failUnless(addon)
     for att in addon.latest.attachments.all():
         self.failUnless(os.path.isfile(
             os.path.join(settings.UPLOAD_DIR, att.path)))
     self.failUnless(
             'main' in [m.filename for m in addon.latest.modules.all()])
     self.failUnless(('attachment', 'txt') in [(a.filename, a.ext)
         for a in addon.latest.attachments.all()])
Ejemplo n.º 4
0
 def test_create_addon_from_xpi(self):
     path_xpi = os.path.join(settings.ROOT,
                             'apps/jetpack/tests/sample_addon.xpi')
     addon = create_package_from_xpi(path_xpi, self.author)
     self.failUnless(addon)
     for att in addon.latest.attachments.all():
         self.failUnless(
             os.path.isfile(os.path.join(settings.UPLOAD_DIR, att.path)))
     self.failUnless(
         'main' in [m.filename for m in addon.latest.modules.all()])
     self.failUnless(('attachment',
                      'txt') in [(a.filename, a.ext)
                                 for a in addon.latest.attachments.all()])
Ejemplo n.º 5
0
    def test_create_addon_from_xpi_with_libs(self):
        libs = ['sample_library']
        path_xpi = os.path.join(
                settings.ROOT, 'apps/jetpack/tests/sample_addon_with_libs.xpi')
        addon = create_package_from_xpi(path_xpi, self.author, libs=libs)

        eq_(len(addon.latest.dependencies.all()), 1)
        lib = addon.latest.dependencies.all()[0]
        self.failUnless(lib.package.name in libs)
        eq_(len(lib.attachments.all()), 1)
        att = lib.attachments.all()[0]
        eq_(('attachment', 'txt'), (att.filename, att.ext))
        self.failUnless(os.path.isfile(
            os.path.join(settings.UPLOAD_DIR, att.path)))
Ejemplo n.º 6
0
    def test_create_addon_from_xpi_with_libs(self):
        libs = ['sample_library']
        path_xpi = os.path.join(
            settings.ROOT, 'apps/jetpack/tests/sample_addon_with_libs.xpi')
        addon = create_package_from_xpi(path_xpi, self.author, libs=libs)

        eq_(len(addon.latest.dependencies.all()), 1)
        lib = addon.latest.dependencies.all()[0]
        self.failUnless(lib.package.name in libs)
        eq_(len(lib.attachments.all()), 1)
        att = lib.attachments.all()[0]
        eq_(('attachment', 'txt'), (att.filename, att.ext))
        self.failUnless(
            os.path.isfile(os.path.join(settings.UPLOAD_DIR, att.path)))
Ejemplo n.º 7
0
def upload_xpi(request):
    """
    upload XPI and create Addon and eventual Libraries
    """
    xpi = request.FILES['xpi']
    temp_dir = tempfile.mkdtemp()
    path = os.path.join(temp_dir, xpi.name)
    xpi_file = codecs.open(path, mode='wb+')
    for chunk in xpi.chunks():
        xpi_file.write(chunk)
    xpi_file.close()
    try:
        addon = create_package_from_xpi(path, request.user)
    except Exception, err:
        log.warning("Bad file %s" % str(err))
        return HttpResponseForbidden('Wrong file')
Ejemplo n.º 8
0
def upload_xpi(request):
    """
    upload XPI and create Addon and eventual Libraries
    """
    try:
        xpi = request.FILES["xpi"]
    except KeyError:
        log.warning('No file "xpi" posted')
        return HttpResponseForbidden("No xpi supplied.")

    temp_dir = tempfile.mkdtemp()
    path = os.path.join(temp_dir, xpi.name)
    xpi_file = codecs.open(path, mode="wb+")
    for chunk in xpi.chunks():
        xpi_file.write(chunk)
    xpi_file.close()
    try:
        addon = create_package_from_xpi(path, request.user)
    except Exception, err:
        log.warning("Bad file %s" % str(err))
        return HttpResponseForbidden("Wrong file")
Ejemplo n.º 9
0
def upload_xpi(request):
    """
    upload XPI and create Addon and eventual Libraries
    """
    try:
        xpi = request.FILES['xpi']
    except KeyError:
        log.warning('No file "xpi" posted')
        return HttpResponseForbidden('No xpi supplied.')

    temp_dir = tempfile.mkdtemp()
    path = os.path.join(temp_dir, xpi.name)
    xpi_file = codecs.open(path, mode='wb+')
    for chunk in xpi.chunks():
        xpi_file.write(chunk)
    xpi_file.close()
    try:
        addon = create_package_from_xpi(path, request.user)
    except Exception, err:
        log.warning("Bad file %s" % str(err))
        return HttpResponseForbidden('Wrong file')