Merge pull request #38 from seanmonstar/bug-658375-list_of_SDK_versions_api

API to determine known SDK versions
This commit is contained in:
Sean McArthur 2011-10-05 13:26:49 -07:00
Родитель f23e0c18c8 7f98539550
Коммит 2f02383e0b
3 изменённых файлов: 27 добавлений и 0 удалений

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

@ -17,6 +17,7 @@ from django.core.urlresolvers import reverse
from jetpack.models import SDK, PackageRevision
from repackage import tasks
from jetpack.models import SDK
log = commonware.log.getLogger('f.repackage')
@ -162,3 +163,20 @@ class RepackageViewsTest(TestCase):
'sdk_version': SDKVERSION})
task_args = tasks.low_rebuild.delay.call_args
eq_(task_args[0][2], sdk.get_source_dir())
def test_list_versions_api(self):
"""
/repackage/sdk-versions/ should return a JSON list of
all the SDK versions known to Builder
"""
resp = self.client.get(reverse('repackage_sdk_versions'))
num_of_versions = SDK.objects.all().count()
assert num_of_versions > 1
eq_(200, resp.status_code)
log.debug(resp.content)
data = simplejson.loads(resp.content)
eq_(num_of_versions, len(data))

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

@ -9,4 +9,5 @@ urlpatterns = patterns('repackage.views',
url(r'^rebuild/$', 'rebuild', name='repackage_rebuild'),
url(r'^sdk-versions/$', 'sdk_versions', name='repackage_sdk_versions'),
)

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

@ -191,3 +191,11 @@ def rebuild(request):
return HttpResponse(simplejson.dumps(response),
mimetype='application/json')
def sdk_versions(r):
versions = SDK.objects.all().order_by('id')
response = [sdk.version for sdk in versions]
return HttpResponse(simplejson.dumps(response),
mimetype='application/json')