Merge branch 'fix-categories-yml-only-icon' into 'master'
update: If categories.yml only has icon:, then add name: See merge request fdroid/fdroidserver!1659
This commit is contained in:
commit
d398994ad3
@ -775,7 +775,9 @@ def make_v2(apps, packages, repodir, repodict, requestsdict, signer_fingerprints
|
||||
# include definitions for "auto-defined" categories, e.g. just used in app metadata
|
||||
for category in sorted(categories_used_by_apps):
|
||||
if category not in output['repo'][CATEGORIES_CONFIG_NAME]:
|
||||
output['repo'][CATEGORIES_CONFIG_NAME][category] = {"name": {DEFAULT_LOCALE: category}}
|
||||
output['repo'][CATEGORIES_CONFIG_NAME][category] = dict()
|
||||
if 'name' not in output['repo'][CATEGORIES_CONFIG_NAME][category]:
|
||||
output['repo'][CATEGORIES_CONFIG_NAME][category]['name'] = {DEFAULT_LOCALE: category}
|
||||
# do not include defined categories if no apps use them
|
||||
for category in list(output['repo'].get(CATEGORIES_CONFIG_NAME, list())):
|
||||
if category not in categories_used_by_apps:
|
||||
|
@ -1913,6 +1913,41 @@ class UpdateTest(unittest.TestCase):
|
||||
index['repo'][CATEGORIES_CONFIG_NAME],
|
||||
)
|
||||
|
||||
def test_categories_with_only_icon_defined(self):
|
||||
"""If cateogories.yml only includes the icon, the name should be added."""
|
||||
os.chdir(self.testdir)
|
||||
os.mkdir('config')
|
||||
os.mkdir('metadata')
|
||||
os.mkdir('repo')
|
||||
fdroidserver.common.write_config_file(
|
||||
'repo_pubkey: ffffffffffffffffffffffffffffffffffffffff\n'
|
||||
)
|
||||
testvalue = 'Time'
|
||||
Path('config/time.png').write_text('placeholder')
|
||||
Path('config/categories.yml').write_text(testvalue + ': {icon: time.png}')
|
||||
|
||||
testapk = os.path.join('repo', 'com.politedroid_6.apk')
|
||||
shutil.copy(basedir / testapk, testapk)
|
||||
Path('metadata/com.politedroid.yml').write_text(f'Categories: [{testvalue}]')
|
||||
|
||||
with mock.patch('sys.argv', ['fdroid update', '--delete-unknown', '--nosign']):
|
||||
fdroidserver.update.main()
|
||||
with open('repo/index-v2.json') as fp:
|
||||
index = json.load(fp)
|
||||
self.assertEqual(
|
||||
{
|
||||
'icon': {
|
||||
'en-US': {
|
||||
'name': '/icons/time.png',
|
||||
'sha256': '4097889236a2af26c293033feb964c4cf118c0224e0d063fec0a89e9d0569ef2',
|
||||
'size': 11,
|
||||
}
|
||||
},
|
||||
'name': {'en-US': testvalue},
|
||||
},
|
||||
index['repo'][CATEGORIES_CONFIG_NAME][testvalue],
|
||||
)
|
||||
|
||||
def test_auto_defined_categories_two_apps(self):
|
||||
"""Repos that don't define categories in config/ should use auto-generated."""
|
||||
os.chdir(self.testdir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user