mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-08-18 20:30:09 +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
|
||||
break
|
||||
if make_list:
|
||||
return outlist
|
||||
return sorted(outlist, key=str.lower)
|
||||
return stringmap
|
||||
|
||||
|
||||
@ -1208,6 +1208,8 @@ def _app_to_yaml(app):
|
||||
if field == 'Builds':
|
||||
if app.get('Builds'):
|
||||
cm.update({field: _builds_to_yaml(app)})
|
||||
elif field == 'Categories':
|
||||
cm[field] = sorted(value, key=str.lower)
|
||||
elif field == 'CurrentVersionCode':
|
||||
cm[field] = _field_to_yaml(TYPE_INT, value)
|
||||
elif field == 'AntiFeatures':
|
||||
|
@ -2019,6 +2019,20 @@ class MetadataTest(unittest.TestCase):
|
||||
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):
|
||||
"""Test the functions that post process the YAML input.
|
||||
|
Loading…
Reference in New Issue
Block a user