test load_localized_config() with categories

This commit is contained in:
Hans-Christoph Steiner 2023-05-30 22:43:21 +02:00
parent bc58959315
commit 6b82710039
6 changed files with 76 additions and 3 deletions

View file

@ -546,6 +546,7 @@ include tests/checkupdates.TestCase
include tests/common.TestCase include tests/common.TestCase
include tests/config.py include tests/config.py
include tests/config/antiFeatures.yml include tests/config/antiFeatures.yml
include tests/config/categories.yml
include tests/config/de/antiFeatures.yml include tests/config/de/antiFeatures.yml
include tests/config/fa/antiFeatures.yml include tests/config/fa/antiFeatures.yml
include tests/config/ic_antifeature_ads.xml include tests/config/ic_antifeature_ads.xml

View file

@ -2694,6 +2694,23 @@ class CommonTest(unittest.TestCase):
p = Path(os.path.dirname(__file__) + '/repo' + v['icon']['en-US']['name']) p = Path(os.path.dirname(__file__) + '/repo' + v['icon']['en-US']['name'])
self.assertTrue(p.exists()) self.assertTrue(p.exists())
def test_load_localized_config_categories(self):
"""It should load"""
categories = fdroidserver.common.load_localized_config('categories', 'repo')
self.assertEqual(
[
'Time',
'Development',
'GuardianProject',
'Multimedia',
'Phone & SMS',
'Security',
'System',
],
list(categories.keys()),
)
self.assertEqual(['en-US'], list(categories['GuardianProject']['name'].keys()))
if __name__ == "__main__": if __name__ == "__main__":
os.chdir(os.path.dirname(__file__)) os.chdir(os.path.dirname(__file__))

View file

@ -0,0 +1,14 @@
Time:
name: Time
Development:
name: Development
GuardianProject:
name: Guardian Project
Multimedia:
name: Multimedia
Phone & SMS:
name: Phone & SMS
Security:
name: Security
System:
name: System

View file

@ -3,8 +3,8 @@
"version": 20002, "version": 20002,
"index": { "index": {
"name": "/index-v2.json", "name": "/index-v2.json",
"sha256": "ba000a3f5e1935d338f374c50cae529b8ce6d988ab3ed67c7a8cf437502f81ad", "sha256": "7117ee6ff4ff2dd71ec3f3d3ad2ef7e9fd4afead9b1f2d39d0b224a1812e78b5",
"size": 52481, "size": 53233,
"numPackages": 10 "numPackages": 10
}, },
"diffs": {} "diffs": {}

View file

@ -498,6 +498,43 @@
} }
} }
}, },
"categories": {
"Time": {
"name": {
"en-US": "Time"
}
},
"Development": {
"name": {
"en-US": "Development"
}
},
"GuardianProject": {
"name": {
"en-US": "Guardian Project"
}
},
"Multimedia": {
"name": {
"en-US": "Multimedia"
}
},
"Phone & SMS": {
"name": {
"en-US": "Phone & SMS"
}
},
"Security": {
"name": {
"en-US": "Security"
}
},
"System": {
"name": {
"en-US": "System"
}
}
},
"requests": { "requests": {
"install": [ "install": [
"org.adaway" "org.adaway"

View file

@ -702,7 +702,11 @@ echo "Description: |" >> metadata/fake.yml
echo " this is fake" >> metadata/fake.yml echo " this is fake" >> metadata/fake.yml
# fake that no JDKs are available # fake that no JDKs are available
echo 'java_paths: {}' > config.yml cat > config.yml <<EOF
categories:
- Internet
java_paths: {}
EOF
LOCAL_COPY_DIR=`create_test_dir`/fdroid LOCAL_COPY_DIR=`create_test_dir`/fdroid
mkdir -p $LOCAL_COPY_DIR/repo mkdir -p $LOCAL_COPY_DIR/repo