Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/olympia/addons/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,10 @@ def validate(self, data):
def _save_icon(self, uploaded_icon):
# This is only used during update. For create it's impossible to send the icon
# as formdata while also sending json for `version`.

if self.instance.type == amo.ADDON_STATICTHEME:
raise exceptions.ValidationError(gettext('Themes do not support icons.'))

if uploaded_icon:
original = self.instance.get_icon_path('original')

Expand Down
13 changes: 13 additions & 0 deletions src/olympia/addons/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,15 @@ def patch_with_error(filename):
assert alog.user == self.user
assert alog.action == amo.LOG.CHANGE_MEDIA.id

def test_upload_icon_theme_raises(self):
self.addon.update(type=amo.ADDON_STATICTHEME)
response = self.request(
data={'icon': _get_upload('mozilla-sq.png')},
format='multipart',
)
assert response.status_code == 400
assert response.data == ['Themes do not support icons.']

@patch('olympia.addons.serializers.remove_icons')
def _test_delete_icon(self, request_data, request_format, remove_icons_mock):
self.addon.update(icon_type='image/png')
Expand Down Expand Up @@ -3172,6 +3181,10 @@ def test_upload_icon(self):
# It's not possible to send formdata format with nested json
pass

def test_upload_icon_theme_raises(self):
# It's not possible to send formdata format with nested json
pass

def test_delete_icon_formdata(self):
# It's not possible to send formdata format with nested json
pass
Expand Down
Loading