mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-11 23:23:27 +02:00
metadata: case-insensitive sort for AntiFeatures Categories
This commit is contained in:
parent
2efc9437ab
commit
d3521d7374
@ -1127,7 +1127,7 @@ def _format_stringmap(appid, field, stringmap, versionCode=None):
|
|||||||
make_list = False
|
make_list = False
|
||||||
break
|
break
|
||||||
if make_list:
|
if make_list:
|
||||||
return outlist
|
return sorted(outlist, key=str.lower)
|
||||||
return stringmap
|
return stringmap
|
||||||
|
|
||||||
|
|
||||||
@ -1208,6 +1208,8 @@ def _app_to_yaml(app):
|
|||||||
if field == 'Builds':
|
if field == 'Builds':
|
||||||
if app.get('Builds'):
|
if app.get('Builds'):
|
||||||
cm.update({field: _builds_to_yaml(app)})
|
cm.update({field: _builds_to_yaml(app)})
|
||||||
|
elif field == 'Categories':
|
||||||
|
cm[field] = sorted(value, key=str.lower)
|
||||||
elif field == 'CurrentVersionCode':
|
elif field == 'CurrentVersionCode':
|
||||||
cm[field] = _field_to_yaml(TYPE_INT, value)
|
cm[field] = _field_to_yaml(TYPE_INT, value)
|
||||||
elif field == 'AntiFeatures':
|
elif field == 'AntiFeatures':
|
||||||
|
@ -2019,6 +2019,20 @@ class MetadataTest(unittest.TestCase):
|
|||||||
appid, field, {afname: {'uz': 'a', locale: 'b', 'zh': 'c'}}, versionCode
|
appid, field, {afname: {'uz': 'a', locale: 'b', 'zh': 'c'}}, versionCode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_app_to_yaml_one_category(self):
|
||||||
|
"""Categories does not get simplified to string when outputting YAML."""
|
||||||
|
self.assertEqual(
|
||||||
|
metadata._app_to_yaml({'Categories': ['one']}),
|
||||||
|
{'Categories': ['one']},
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_app_to_yaml_categories(self):
|
||||||
|
"""Sort case-insensitive before outputting YAML."""
|
||||||
|
self.assertEqual(
|
||||||
|
metadata._app_to_yaml({'Categories': ['c', 'a', 'B']}),
|
||||||
|
{'Categories': ['a', 'B', 'c']},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PostMetadataParseTest(unittest.TestCase):
|
class PostMetadataParseTest(unittest.TestCase):
|
||||||
"""Test the functions that post process the YAML input.
|
"""Test the functions that post process the YAML input.
|
||||||
|
Loading…
Reference in New Issue
Block a user