Beispiel #1
0
 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)
Beispiel #2
0
 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)
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
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
Beispiel #7
0
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
Beispiel #8
0
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
Beispiel #9
0
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
Beispiel #10
0
    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)
Beispiel #11
0
    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)
Beispiel #12
0
 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)
Beispiel #13
0
 def test_get_case(self):
     eq_(reverse_name_lookup("delicious bookmarks", addon_type=amo.ADDON_EXTENSION), 3615)
Beispiel #14
0
 def test_get_strip(self):
     eq_(reverse_name_lookup('Delicious Bookmarks   '), 3615)
Beispiel #15
0
 def test_get_strip(self):
     eq_(
         reverse_name_lookup('Delicious Bookmarks   ',
                             addon_type=amo.ADDON_EXTENSION), 3615)
Beispiel #16
0
 def test_get_case(self):
     eq_(
         reverse_name_lookup('delicious bookmarks',
                             addon_type=amo.ADDON_EXTENSION), 3615)
Beispiel #17
0
 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)
Beispiel #18
0
 def test_get_case(self):
     eq_(reverse_name_lookup('delicious bookmarks'), 3615)
Beispiel #19
0
 def test_get_strip(self):
     eq_(reverse_name_lookup('Delicious Bookmarks   '), 3615)
Beispiel #20
0
 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)
Beispiel #21
0
 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)
Beispiel #22
0
 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)
Beispiel #23
0
 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)
Beispiel #24
0
 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)
Beispiel #25
0
 def test_get_case(self):
     eq_(reverse_name_lookup('delicious bookmarks'), 3615)
Beispiel #26
0
 def test_get_strip(self):
     eq_(reverse_name_lookup("Delicious Bookmarks   ", addon_type=amo.ADDON_EXTENSION), 3615)