Add ability to choose version of the SDK to be used with repackage

fixes https://bugzilla.mozilla.org/show_bug.cgi?id=685280
This commit is contained in:
Piotr Zalewa 2011-09-26 14:49:03 +01:00
Родитель bacb702c6b
Коммит 12dca98e68
3 изменённых файлов: 44 добавлений и 10 удалений

Просмотреть файл

@ -15,6 +15,7 @@ from utils.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
from jetpack.models import SDK, PackageRevision
from repackage import tasks
log = commonware.log.getLogger('f.repackage')
@ -140,3 +141,24 @@ class RepackageViewsTest(TestCase):
'secret': settings.AMO_SECRET_KEY})
task_args = tasks.low_rebuild.delay.call_args
eq_(task_args[1]['package_overrides']['version'], 'test-sdk-1.0')
def test_repackage_with_chosen_sdk(self):
SDKVERSION = 'test'
SDKDIR = 'not/existing/dir'
# create new package revision for the core lib
corelib = SDK.objects.latest('pk').core_lib
corelib.save()
sdk = SDK.objects.create(
version=SDKVERSION,
dir=SDKDIR,
core_lib=corelib)
file_pre = os.path.join(settings.ROOT, 'apps/xpi/tests/sample_addons/')
tasks.low_rebuild.delay = Mock(return_value=None)
with open(os.path.join(file_pre, self.sample_addons[1])) as f:
response = self.client.post(self.rebuild_url, {
'upload': f,
'version': 'test-sdk-{sdk_version}',
'secret': settings.AMO_SECRET_KEY,
'sdk_version': SDKVERSION})
task_args = tasks.low_rebuild.delay.call_args
eq_(task_args[0][2], sdk.get_source_dir())

Просмотреть файл

@ -10,6 +10,7 @@ from django.http import (HttpResponse, HttpResponseBadRequest,
HttpResponseForbidden)
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.shortcuts import get_object_or_404
from jetpack.models import SDK
from utils.helpers import get_random_string
@ -77,6 +78,7 @@ def rebuild(request):
location = request.POST.get('location', None)
addons = request.POST.get('addons', None)
upload = request.FILES.get('upload', None)
if not location and not upload and not addons:
log.error("Rebuild requested but files weren't specified. Rejecting.")
return HttpResponseBadRequest('Please provide XPI files to rebuild')
@ -85,17 +87,24 @@ def rebuild(request):
"Rejecting")
return HttpResponseBadRequest('Please provide XPI files to rebuild')
sdk_source_dir = (settings.REPACKAGE_SDK_SOURCE
or _get_latest_sdk_source_dir())
sdk_manifest = '%s/packages/%s/package.json' % (sdk_source_dir, 'addon-kit')
try:
handle = open(sdk_manifest)
except Exception, err:
log.critical("Problems loading SDK manifest\n%s" % str(err))
raise
# locate SDK source directory
sdk_version = request.POST.get('sdk_version', None)
if sdk_version:
sdk = get_object_or_404(SDK, version=sdk_version)
sdk_source_dir = sdk.get_source_dir()
else:
sdk_version = simplejson.loads(handle.read())['version']
handle.close()
sdk_source_dir = (settings.REPACKAGE_SDK_SOURCE
or _get_latest_sdk_source_dir())
sdk_manifest = '%s/packages/%s/package.json' % (sdk_source_dir, 'addon-kit')
try:
handle = open(sdk_manifest)
except Exception, err:
log.critical("Problems loading SDK manifest\n%s" % str(err))
raise
else:
sdk_version = simplejson.loads(handle.read())['version']
handle.close()
pingback = request.POST.get('pingback', None)
priority = request.POST.get('priority', None)
post = request.POST.urlencode()

Просмотреть файл

@ -45,6 +45,9 @@ tests, main** (optional)
to repackage. Specifically ``"version": "0.1.sdk.{sdk_version}"`` will
be replaced with ``"version": "0.1.sdk.1.0b5"``.
**sdk_version**
version of the SDK which should be used to rebuild the package
Examples of data creation for POST:
-----------------------------------