def test_delete_addon(self): eq_( reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION), 3615) self.addon.delete('farewell my sweet amo, it was a good run') eq_( reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION), None)
def test_update_addon(self): eq_( reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION), 3615) self.addon.name = 'boo' self.addon.save() eq_( reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION), None) eq_(reverse_name_lookup('boo', addon_type=amo.ADDON_EXTENSION), 3615)
def clean_name(name, instance=None): if not instance: log.debug("clean_name called without an instance: %s" % name) if instance: id = reverse_name_lookup(name, instance.is_webapp()) else: id = reverse_name_lookup(name) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError(_("This name is already in use. Please " "choose another.")) return name
def clean_name(name, instance=None): if not instance: log.debug('clean_name called without an instance: %s' % name) if instance: id = reverse_name_lookup(name, instance.is_webapp()) else: id = reverse_name_lookup(name) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError(_('This name is already in use. Please ' 'choose another.')) return name
def clean_name(name, instance=None): if not instance: log.debug('clean_name called without an instance: %s' % name) id = reverse_name_lookup(name) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError(_('This name is already in use. Please ' 'choose another.')) return name
def clean_name(name, instance=None): if not instance: log.debug('clean_name called without an instance: %s' % name) # We don't enforce uniqueness for unlsited addons. if instance and not instance.is_listed: return name id = reverse_name_lookup(name) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError(_('This name is already in use. Please ' 'choose another.')) return name
def clean_name(name, instance=None): if not instance: log.debug('clean_name called without an instance: %s' % name) # We don't enforce uniqueness for unlsited addons. if instance and not instance.is_listed: return name id = reverse_name_lookup(name) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError( _('This name is already in use. Please ' 'choose another.')) return name
def clean_name(name, instance=None, addon_type=None): if not instance: log.debug('clean_name called without an instance: %s' % name) # We don't need to do anything to prevent an unlisted addon name from # clashing with listed addons, because the `reverse_name_lookup` util below # uses the Addon.objects manager, which filters out unlisted addons. if instance and not instance.is_listed: return name assert instance or addon_type if not addon_type: addon_type = instance.type id = reverse_name_lookup(name, addon_type) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError(_('This name is already in use. Please ' 'choose another.')) return name
def clean_name(name, instance=None, addon_type=None): if not instance: log.debug('clean_name called without an instance: %s' % name) # We don't need to do anything to prevent an unlisted addon name from # clashing with listed addons, because the `reverse_name_lookup` util below # uses the Addon.objects manager, which filters out unlisted addons. if instance and not instance.is_listed: return name assert instance or addon_type if not addon_type: addon_type = instance.type id = reverse_name_lookup(name, addon_type) # If we get an id and either there's no instance or the instance.id != id. if id and (not instance or id != instance.id): raise forms.ValidationError( _('This name is already in use. Please ' 'choose another.')) return name
def test_addon_and_app_namespaces(self): eq_(reverse_name_lookup('Delicious Bookmarks', webapp=False), 3615) eq_(reverse_name_lookup('Delicious Bookmarks', webapp=True), None) # Note: The factory creates the app which calls the reverse_name_lookup # in a post_save signal, so no need to call it explicitly here. app = amo.tests.addon_factory(type=amo.ADDON_WEBAPP) self.assertTrue(app.is_webapp()) eq_(reverse_name_lookup(app.name, webapp=False), None) eq_(reverse_name_lookup(app.name, webapp=True), app.id) # Show we can also create an app with the same name as an addon name = 'Delicious Bookmarks' app = amo.tests.addon_factory(name=name, type=amo.ADDON_WEBAPP) self.assertTrue(app.is_webapp()) eq_(reverse_name_lookup(name, webapp=False), 3615) eq_(reverse_name_lookup(name, webapp=True), app.id)
def _setup_other_webapp(self): self._step() # Generate another webapp to test name uniqueness. app = amo.tests.addon_factory(type=amo.ADDON_WEBAPP, name='Cool App') eq_(reverse_name_lookup(app.name, webapp=True), app.id)
def test_get_case(self): eq_(reverse_name_lookup("delicious bookmarks", addon_type=amo.ADDON_EXTENSION), 3615)
def test_get_strip(self): eq_(reverse_name_lookup('Delicious Bookmarks '), 3615)
def test_get_strip(self): eq_( reverse_name_lookup('Delicious Bookmarks ', addon_type=amo.ADDON_EXTENSION), 3615)
def test_get_case(self): eq_( reverse_name_lookup('delicious bookmarks', addon_type=amo.ADDON_EXTENSION), 3615)
def test_delete_addon(self): eq_(reverse_name_lookup('Delicious Bookmarks'), 3615) self.addon.delete('farewell my sweet amo, it was a good run') eq_(reverse_name_lookup('Delicious Bookmarks'), None)
def test_get_case(self): eq_(reverse_name_lookup('delicious bookmarks'), 3615)
def test_update_addon(self): eq_(reverse_name_lookup('Delicious Bookmarks'), 3615) self.addon.name = 'boo' self.addon.save() eq_(reverse_name_lookup('Delicious Bookmarks'), None) eq_(reverse_name_lookup('boo'), 3615)
def test_delete_addon(self): eq_(reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION), 3615) self.addon.delete("farewell my sweet amo, it was a good run") eq_(reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION), None)
def test_update_addon(self): eq_(reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION), 3615) self.addon.name = "boo" self.addon.save() eq_(reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION), None) eq_(reverse_name_lookup("boo", addon_type=amo.ADDON_EXTENSION), 3615)
def test_get_strip(self): eq_(reverse_name_lookup("Delicious Bookmarks ", addon_type=amo.ADDON_EXTENSION), 3615)