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): assert reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) == 3615 self.addon.name = 'boo' self.addon.save() assert reverse_name_lookup('Delicious Bookmarks', addon_type=amo.ADDON_EXTENSION) is None assert reverse_name_lookup('boo', addon_type=amo.ADDON_EXTENSION) == 3615
def test_update_addon(self): assert reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION) self.addon.name = 'boo' self.addon.save() assert not reverse_name_lookup( 'Delicious Bookmarks', amo.ADDON_EXTENSION, self.addon) assert reverse_name_lookup('boo', amo.ADDON_EXTENSION) # Exclude the add-on from search if we have one (in case of an update) assert not reverse_name_lookup('boo', amo.ADDON_EXTENSION, self.addon)
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_update_addon(self): assert reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION) self.addon.name = 'boo' self.addon.save() assert not reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION, self.addon) assert reverse_name_lookup('boo', amo.ADDON_EXTENSION) # Exclude the add-on from search if we have one (in case of an update) assert not reverse_name_lookup('boo', amo.ADDON_EXTENSION, self.addon)
def test_multiple_languages(self): assert reverse_name_lookup('delicious bookmarks', amo.ADDON_EXTENSION) self.addon.name = {'de': 'name', 'en-US': 'name', 'fr': 'name'} self.addon.save() assert not reverse_name_lookup( 'delicious bookmarks', amo.ADDON_EXTENSION) assert reverse_name_lookup('name', amo.ADDON_EXTENSION) assert reverse_name_lookup({'de': 'name'}, amo.ADDON_EXTENSION) assert reverse_name_lookup({'en-US': 'name'}, amo.ADDON_EXTENSION) assert not reverse_name_lookup({'es': 'name'}, amo.ADDON_EXTENSION) # Excludes the add-on instance if given assert not reverse_name_lookup('name', amo.ADDON_EXTENSION, self.addon) assert not reverse_name_lookup( {'de': 'name'}, amo.ADDON_EXTENSION, self.addon)
def test_multiple_languages(self): assert reverse_name_lookup('delicious bookmarks', amo.ADDON_EXTENSION) self.addon.name = {'de': 'name', 'en-US': 'name', 'fr': 'name'} self.addon.save() assert not reverse_name_lookup('delicious bookmarks', amo.ADDON_EXTENSION) assert reverse_name_lookup('name', amo.ADDON_EXTENSION) assert reverse_name_lookup({'de': 'name'}, amo.ADDON_EXTENSION) assert reverse_name_lookup({'en-US': 'name'}, amo.ADDON_EXTENSION) assert not reverse_name_lookup({'es': 'name'}, amo.ADDON_EXTENSION) # Excludes the add-on instance if given assert not reverse_name_lookup('name', amo.ADDON_EXTENSION, self.addon) assert not reverse_name_lookup({'de': 'name'}, amo.ADDON_EXTENSION, self.addon)
def clean_addon_name(name, instance=None, addon_type=None): if not instance: log.debug('clean_addon_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 match = reverse_name_lookup(name, addon_type=addon_type, instance=instance) if match: raise forms.ValidationError( _('This name is already in use. Please choose another.')) return name
def clean_addon_name(name, instance=None, addon_type=None): if not instance: log.debug('clean_addon_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_delete_addon(self): assert reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION) == 3615 self.addon.delete("farewell my sweet amo, it was a good run") assert reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION) is None
def test_get_strip(self): eq_( reverse_name_lookup('Delicious Bookmarks ', addon_type=amo.ADDON_EXTENSION), 3615)
def test_get_case(self): assert reverse_name_lookup('delicious bookmarks', amo.ADDON_EXTENSION)
def test_get_strip(self): assert reverse_name_lookup( 'Delicious Bookmarks ', amo.ADDON_EXTENSION)
def test_get_case(self): eq_( reverse_name_lookup('delicious bookmarks', addon_type=amo.ADDON_EXTENSION), 3615)
def test_delete_addon(self): assert reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION) self.addon.delete('farewell my sweet amo, it was a good run') assert not reverse_name_lookup( 'Delicious Bookmarks', amo.ADDON_EXTENSION)
def test_get_case(self): eq_(reverse_name_lookup("delicious bookmarks", addon_type=amo.ADDON_EXTENSION), 3615)
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)
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): assert reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION) == 3615 self.addon.name = "boo" self.addon.save() assert reverse_name_lookup("Delicious Bookmarks", addon_type=amo.ADDON_EXTENSION) is None assert reverse_name_lookup("boo", addon_type=amo.ADDON_EXTENSION) == 3615
def test_get_strip(self): assert reverse_name_lookup('Delicious Bookmarks ', amo.ADDON_EXTENSION)
def test_delete_addon(self): assert reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION) self.addon.delete('farewell my sweet amo, it was a good run') assert not reverse_name_lookup('Delicious Bookmarks', amo.ADDON_EXTENSION)