mirror of https://gitlab.com/bashrc2/epicyon
Test for getting the languages list
parent
1a54698ec8
commit
f2b4de3044
12
languages.py
12
languages.py
|
@ -47,15 +47,21 @@ def setActorLanguages(baseDir: str, actorJson: {}, languagesStr: str) -> None:
|
||||||
elif ' ' in languagesStr:
|
elif ' ' in languagesStr:
|
||||||
separator = ' '
|
separator = ' '
|
||||||
langList = languagesStr.lower().split(separator)
|
langList = languagesStr.lower().split(separator)
|
||||||
langList2 = []
|
langList2 = ''
|
||||||
for lang in langList:
|
for lang in langList:
|
||||||
lang = lang.strip()
|
lang = lang.strip()
|
||||||
if baseDir:
|
if baseDir:
|
||||||
languageFilename = baseDir + '/translations/' + lang + '.json'
|
languageFilename = baseDir + '/translations/' + lang + '.json'
|
||||||
if os.path.isfile(languageFilename):
|
if os.path.isfile(languageFilename):
|
||||||
langList2.append(lang)
|
if langList2:
|
||||||
|
langList2 += ', ' + lang.strip()
|
||||||
|
else:
|
||||||
|
langList2 += lang.strip()
|
||||||
else:
|
else:
|
||||||
langList2.append(lang)
|
if langList2:
|
||||||
|
langList2 += ', ' + lang.strip()
|
||||||
|
else:
|
||||||
|
langList2 += lang.strip()
|
||||||
|
|
||||||
# remove any existing value
|
# remove any existing value
|
||||||
propertyFound = None
|
propertyFound = None
|
||||||
|
|
11
tests.py
11
tests.py
|
@ -42,6 +42,7 @@ from follow import clearFollowers
|
||||||
from follow import sendFollowRequestViaServer
|
from follow import sendFollowRequestViaServer
|
||||||
from follow import sendUnfollowRequestViaServer
|
from follow import sendUnfollowRequestViaServer
|
||||||
from siteactive import siteIsActive
|
from siteactive import siteIsActive
|
||||||
|
from utils import getActorLanguagesList
|
||||||
from utils import getCategoryTypes
|
from utils import getCategoryTypes
|
||||||
from utils import getSupportedLanguages
|
from utils import getSupportedLanguages
|
||||||
from utils import setConfigParam
|
from utils import setConfigParam
|
||||||
|
@ -5084,10 +5085,12 @@ def _testSetActorLanguages():
|
||||||
assert len(actorJson['attachment']) == 1
|
assert len(actorJson['attachment']) == 1
|
||||||
assert actorJson['attachment'][0]['name'] == 'Languages'
|
assert actorJson['attachment'][0]['name'] == 'Languages'
|
||||||
assert actorJson['attachment'][0]['type'] == 'PropertyValue'
|
assert actorJson['attachment'][0]['type'] == 'PropertyValue'
|
||||||
assert len(actorJson['attachment'][0]['value']) == 3
|
assert isinstance(actorJson['attachment'][0]['value'], str)
|
||||||
assert 'en' in actorJson['attachment'][0]['value']
|
assert ',' in actorJson['attachment'][0]['value']
|
||||||
assert 'fr' in actorJson['attachment'][0]['value']
|
langList = getActorLanguagesList(actorJson)
|
||||||
assert 'es' in actorJson['attachment'][0]['value']
|
assert 'en' in langList
|
||||||
|
assert 'fr' in langList
|
||||||
|
assert 'es' in langList
|
||||||
languagesStr = getActorLanguages(actorJson)
|
languagesStr = getActorLanguages(actorJson)
|
||||||
assert languagesStr == 'en / es / fr'
|
assert languagesStr == 'en / es / fr'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue