Skip to content
Merged
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
8 changes: 4 additions & 4 deletions core/concepts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def get_mappings(self, obj): # pylint: disable=too-many-locals
) if is_collection else obj.get_bidirectional_mappings()
if not include_retired:
mappings = mappings.filter(retired=False)
return serializer_class(mappings, many=True).data
return serializer_class(mappings.order_by('id'), many=True).data
if self.include_direct_mappings:
mappings = obj.get_unidirectional_mappings_for_collection(
parent_uri, collection_version) if is_collection else obj.get_unidirectional_mappings()
Expand All @@ -307,7 +307,7 @@ def get_mappings(self, obj): # pylint: disable=too-many-locals
mappings = mappings.filter(to_source_url__in=target_repo_urls)
if not include_retired:
mappings = mappings.filter(retired=False)
return serializer_class(mappings, many=True).data
return serializer_class(mappings.order_by('id'), many=True).data

return []

Expand Down Expand Up @@ -726,11 +726,11 @@ def get_mappings(self, obj):
mappings = obj.get_bidirectional_mappings_for_collection(
parent_uri, collection_version
) if is_collection else obj.get_bidirectional_mappings()
return MappingDetailSerializer(mappings, many=True, context=context).data
return MappingDetailSerializer(mappings.order_by('id'), many=True, context=context).data
if self.include_direct_mappings:
mappings = obj.get_unidirectional_mappings_for_collection(
parent_uri, collection_version) if is_collection else obj.get_unidirectional_mappings()
return MappingDetailSerializer(mappings, many=True, context=context).data
return MappingDetailSerializer(mappings.order_by('id'), many=True, context=context).data

return []

Expand Down
6 changes: 5 additions & 1 deletion core/integration_tests/tests_concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4702,4 +4702,8 @@ def test_inverse_mappings_are_unchanged(self):
batched = self.client.get(url).data
with patch.object(ConceptAbstractSerializer, 'preload_page', lambda *args: None):
per_concept = self.client.get(url).data
self.assertEqual(batched, per_concept)
# plain lists, so a failure shows the differing element
self.assertEqual(list(batched), list(per_concept))
for row in batched:
mapping_ids = [int(mapping['uuid']) for mapping in row['mappings']]
self.assertEqual(mapping_ids, sorted(mapping_ids))
Loading