Revert "UUID ALL THE APPS! (bug 814131)"
This reverts commit def797bb14
.
This commit is contained in:
Родитель
a56d7374cf
Коммит
283fab1a46
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import amo
|
||||
from mkt.webapps.models import Webapp
|
||||
|
||||
|
||||
def run():
|
||||
"""Add uuid to apps that don't have one."""
|
||||
for app in (Webapp.uncached.filter(guid=None)
|
||||
.exclude(status=amo.STATUS_DELETED)
|
||||
.no_transforms()):
|
||||
app.save()
|
|
@ -297,8 +297,7 @@ class TestCreateWebApp(BaseWebAppTest):
|
|||
addon = self.post_addon()
|
||||
eq_(addon.type, amo.ADDON_WEBAPP)
|
||||
eq_(addon.is_packaged, False)
|
||||
assert addon.guid is not None, (
|
||||
'Expected app to have a UUID assigned to guid')
|
||||
eq_(addon.guid, None)
|
||||
eq_(unicode(addon.name), u'MozillaBall ょ')
|
||||
eq_(addon.slug, 'app-%s' % addon.id)
|
||||
eq_(addon.app_slug, u'mozillaball-ょ')
|
||||
|
@ -444,8 +443,7 @@ class TestCreatePackagedApp(BasePackagedAppTest):
|
|||
eq_(addon.type, amo.ADDON_WEBAPP)
|
||||
eq_(addon.current_version.version, '1.0')
|
||||
eq_(addon.is_packaged, True)
|
||||
assert addon.guid is not None, (
|
||||
'Expected app to have a UUID assigned to guid')
|
||||
eq_(addon.guid, None)
|
||||
eq_(unicode(addon.name), u'Packaged MozillaBall ょ')
|
||||
eq_(addon.slug, 'app-%s' % addon.id)
|
||||
eq_(addon.app_slug, u'packaged-mozillaball-ょ')
|
||||
|
|
|
@ -110,7 +110,6 @@ class Webapp(Addon):
|
|||
# Make sure we have the right type.
|
||||
self.type = amo.ADDON_WEBAPP
|
||||
self.clean_slug(slug_field='app_slug')
|
||||
self.assign_uuid()
|
||||
creating = not self.id
|
||||
super(Addon, self).save(**kw)
|
||||
if creating:
|
||||
|
@ -669,22 +668,6 @@ class Webapp(Addon):
|
|||
return
|
||||
return packaged.sign(version_pk, reviewer=reviewer)
|
||||
|
||||
def assign_uuid(self):
|
||||
"""Generates a UUID if self.guid is not already set."""
|
||||
if not self.guid:
|
||||
max_tries = 10
|
||||
tried = 1
|
||||
guid = str(uuid.uuid4())
|
||||
while tried <= max_tries:
|
||||
if not Webapp.objects.filter(guid=guid).exists():
|
||||
self.guid = guid
|
||||
break
|
||||
else:
|
||||
guid = str(uuid.uuid4())
|
||||
tried += 1
|
||||
else:
|
||||
raise Exception('Could not auto-generate a unique UUID')
|
||||
|
||||
|
||||
# Pull all translated_fields from Addon over to Webapp.
|
||||
Webapp._meta.translated_fields = Addon._meta.translated_fields
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from datetime import datetime, timedelta
|
||||
import json
|
||||
import unittest
|
||||
import uuid
|
||||
import zipfile
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -268,22 +267,6 @@ class TestWebapp(amo.tests.TestCase):
|
|||
webapp = Webapp.objects.create(manifest_url='http://foo.com')
|
||||
eq_(webapp.is_packaged, False)
|
||||
|
||||
def test_assign_uuid(self):
|
||||
app = Webapp()
|
||||
eq_(app.guid, None)
|
||||
app.save()
|
||||
assert app.guid is not None, (
|
||||
'Expected app to have a UUID assigned to guid')
|
||||
|
||||
@mock.patch.object(uuid, 'uuid4', 'abcdef')
|
||||
def test_assign_uuid_max_tries(self):
|
||||
# Create another webapp with and set the guid.
|
||||
Webapp.objects.create(guid='abcdef')
|
||||
# Now `assign_uuid()` should fail.
|
||||
app = Webapp()
|
||||
with self.assertRaises(Exception):
|
||||
app.assign_uuid()
|
||||
|
||||
|
||||
class TestWebappVersion(amo.tests.TestCase):
|
||||
fixtures = ['base/platforms']
|
||||
|
|
Загрузка…
Ссылка в новой задаче