Don't fail on deletion of disabled add-ons with an empty guid (#16613)
This commit is contained in:
Родитель
11f4549f2b
Коммит
bee0512202
|
@ -555,6 +555,8 @@ class Addon(OnChangeMixin, ModelBase):
|
|||
self.update_status()
|
||||
|
||||
def deny_resubmission(self):
|
||||
if not self.guid:
|
||||
raise RuntimeError('No GUID on this add-on')
|
||||
if self.is_guid_denied:
|
||||
raise RuntimeError('GUID already denied')
|
||||
|
||||
|
|
|
@ -698,6 +698,14 @@ class TestAddonModels(TestCase):
|
|||
self._delete(3615)
|
||||
assert DeniedGuid.objects.filter(guid=addon.guid).exists()
|
||||
|
||||
def test_delete_disabled_addon_no_guid(self):
|
||||
addon = Addon.unfiltered.get(pk=3615)
|
||||
addon.update(status=amo.STATUS_DISABLED, guid=None)
|
||||
self._delete(3615)
|
||||
# Adding it to the DeniedGuid would be pointless since it's empty. The
|
||||
# important thing is that the delete() calls succeeds.
|
||||
assert not DeniedGuid.objects.filter(guid=addon.guid).exists()
|
||||
|
||||
def test_delete_unknown_type(self):
|
||||
"""
|
||||
Test making sure deleting add-ons with an unknown type, like old
|
||||
|
@ -2920,6 +2928,11 @@ class TestAddonAndDeniedGuid(TestCase):
|
|||
with pytest.raises(RuntimeError):
|
||||
addon.deny_resubmission()
|
||||
|
||||
def test_deny_empty_guid(self):
|
||||
addon = addon_factory(guid=None)
|
||||
with pytest.raises(RuntimeError):
|
||||
addon.deny_resubmission()
|
||||
|
||||
def test_allow_resubmission(self):
|
||||
addon = addon_factory()
|
||||
addon.deny_resubmission()
|
||||
|
|
Загрузка…
Ссылка в новой задаче