From 283fab1a46771c04a005119ba61ef0583eed1dcd Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Wed, 5 Dec 2012 09:53:02 -0800 Subject: [PATCH] Revert "UUID ALL THE APPS! (bug 814131)" This reverts commit def797bb14a44be7595438de2205829df647a4cf. --- migrations/506-apps-add-uuid.py | 11 ----------- mkt/submit/tests/test_views.py | 6 ++---- mkt/webapps/models.py | 17 ----------------- mkt/webapps/tests/test_models.py | 17 ----------------- 4 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 migrations/506-apps-add-uuid.py diff --git a/migrations/506-apps-add-uuid.py b/migrations/506-apps-add-uuid.py deleted file mode 100644 index c297492e8f..0000000000 --- a/migrations/506-apps-add-uuid.py +++ /dev/null @@ -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() diff --git a/mkt/submit/tests/test_views.py b/mkt/submit/tests/test_views.py index 7f32621595..ee9a1e9948 100644 --- a/mkt/submit/tests/test_views.py +++ b/mkt/submit/tests/test_views.py @@ -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-ょ') diff --git a/mkt/webapps/models.py b/mkt/webapps/models.py index 9da3c22701..bbe623ec39 100644 --- a/mkt/webapps/models.py +++ b/mkt/webapps/models.py @@ -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 diff --git a/mkt/webapps/tests/test_models.py b/mkt/webapps/tests/test_models.py index dfc528ec50..b486e5d5df 100644 --- a/mkt/webapps/tests/test_models.py +++ b/mkt/webapps/tests/test_models.py @@ -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']