Expose `current_version.is_strict_compatibility_enabled` in discovery API (#9524)
Expose `current_version.is_strict_compatibility_enabled` in discovery API
This commit is contained in:
Родитель
d332af5249
Коммит
4ceea8b454
|
@ -26,7 +26,7 @@ Firefox (about:addons).
|
|||
:>json string results[].heading: The heading for this item. May contain some HTML tags.
|
||||
:>json string|null results[].description: The description for this item, if any. May contain some HTML tags.
|
||||
:>json boolean results[].is_recommendation: If this item was from the recommendation service, rather than static curated content.
|
||||
:>json object results[].addon: The :ref:`add-on <addon-detail-object>` for this item. Only a subset of fields are present: ``id``, ``current_version`` (with only the ``compatibility`` and ``files`` fields present), ``guid``, ``icon_url``, ``name``, ``previews``, ``slug``, ``theme_data``, ``type`` and ``url``.
|
||||
:>json object results[].addon: The :ref:`add-on <addon-detail-object>` for this item. Only a subset of fields are present: ``id``, ``current_version`` (with only the ``compatibility``, ``is_strict_compatibility_enabled`` and ``files`` fields present), ``guid``, ``icon_url``, ``name``, ``previews``, ``slug``, ``theme_data``, ``type`` and ``url``.
|
||||
|
||||
|
||||
-------------------------
|
||||
|
|
|
@ -278,3 +278,4 @@ v4 API changelog
|
|||
* 2018-09-27: backed out "localised field values are always returned as objects" change from 2018-07-19 from `v4` API. This is intended to be temporary change while addons-frontend upgrades.
|
||||
On addons-dev and addons stage enviroments the previous behavior is available as `api/v4dev`. The `v4dev` api is not available on AMO production server.
|
||||
https://github.com/mozilla/addons-server/issues/9467
|
||||
* 2018-10-04: added ``is_strict_compatibility_enabled`` to discovery API ``addons.current_version`` object. This change was also backported to the `v3` API. https://github.com/mozilla/addons-server/issues/9520
|
||||
|
|
|
@ -20,7 +20,7 @@ class DiscoveryEditorialContentSerializer(serializers.ModelSerializer):
|
|||
|
||||
class DiscoveryVersionSerializer(VersionSerializer):
|
||||
class Meta:
|
||||
fields = ('compatibility', 'files',)
|
||||
fields = ('compatibility', 'is_strict_compatibility_enabled', 'files',)
|
||||
model = Version
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,35 @@ from olympia.discovery.utils import replace_extensions
|
|||
|
||||
|
||||
class DiscoveryTestMixin(object):
|
||||
def _check_disco_addon_version(self, data, version):
|
||||
assert data['compatibility']
|
||||
assert len(data['compatibility']) == len(version.compatible_apps)
|
||||
for app, compat in version.compatible_apps.items():
|
||||
assert data['compatibility'][app.short] == {
|
||||
'min': compat.min.version,
|
||||
'max': compat.max.version
|
||||
}
|
||||
assert data['is_strict_compatibility_enabled'] is False
|
||||
assert data['files']
|
||||
assert len(data['files']) == 1
|
||||
|
||||
result_file = data['files'][0]
|
||||
file_ = version.files.latest('pk')
|
||||
assert result_file['id'] == file_.pk
|
||||
assert result_file['created'] == (
|
||||
file_.created.replace(microsecond=0).isoformat() + 'Z')
|
||||
assert result_file['hash'] == file_.hash
|
||||
assert result_file['is_restart_required'] == file_.is_restart_required
|
||||
assert result_file['is_webextension'] == file_.is_webextension
|
||||
assert (
|
||||
result_file['is_mozilla_signed_extension'] ==
|
||||
file_.is_mozilla_signed_extension)
|
||||
|
||||
assert result_file['size'] == file_.size
|
||||
assert result_file['status'] == amo.STATUS_CHOICES_API[file_.status]
|
||||
assert result_file['url'] == file_.get_url_path(src='')
|
||||
assert result_file['permissions'] == file_.webext_permissions_list
|
||||
|
||||
def _check_disco_addon(self, result, item, flat_name=False):
|
||||
addon = item.addon
|
||||
assert result['addon']['id'] == item.addon_id == addon.pk
|
||||
|
@ -28,6 +57,9 @@ class DiscoveryTestMixin(object):
|
|||
assert result['heading'] == item.heading
|
||||
assert result['description'] == item.description
|
||||
|
||||
self._check_disco_addon_version(
|
||||
result['addon']['current_version'], addon.current_version)
|
||||
|
||||
def _check_disco_theme(self, result, item, flat_name=False):
|
||||
addon = item.addon
|
||||
assert result['addon']['id'] == item.addon_id == addon.pk
|
||||
|
|
Загрузка…
Ссылка в новой задаче