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:
|
||||
separator = ' '
|
||||
langList = languagesStr.lower().split(separator)
|
||||
langList2 = []
|
||||
langList2 = ''
|
||||
for lang in langList:
|
||||
lang = lang.strip()
|
||||
if baseDir:
|
||||
languageFilename = baseDir + '/translations/' + lang + '.json'
|
||||
if os.path.isfile(languageFilename):
|
||||
langList2.append(lang)
|
||||
if langList2:
|
||||
langList2 += ', ' + lang.strip()
|
||||
else:
|
||||
langList2 += lang.strip()
|
||||
else:
|
||||
langList2.append(lang)
|
||||
if langList2:
|
||||
langList2 += ', ' + lang.strip()
|
||||
else:
|
||||
langList2 += lang.strip()
|
||||
|
||||
# remove any existing value
|
||||
propertyFound = None
|
||||
|
|
11
tests.py
11
tests.py
|
@ -42,6 +42,7 @@ from follow import clearFollowers
|
|||
from follow import sendFollowRequestViaServer
|
||||
from follow import sendUnfollowRequestViaServer
|
||||
from siteactive import siteIsActive
|
||||
from utils import getActorLanguagesList
|
||||
from utils import getCategoryTypes
|
||||
from utils import getSupportedLanguages
|
||||
from utils import setConfigParam
|
||||
|
@ -5084,10 +5085,12 @@ def _testSetActorLanguages():
|
|||
assert len(actorJson['attachment']) == 1
|
||||
assert actorJson['attachment'][0]['name'] == 'Languages'
|
||||
assert actorJson['attachment'][0]['type'] == 'PropertyValue'
|
||||
assert len(actorJson['attachment'][0]['value']) == 3
|
||||
assert 'en' in actorJson['attachment'][0]['value']
|
||||
assert 'fr' in actorJson['attachment'][0]['value']
|
||||
assert 'es' in actorJson['attachment'][0]['value']
|
||||
assert isinstance(actorJson['attachment'][0]['value'], str)
|
||||
assert ',' in actorJson['attachment'][0]['value']
|
||||
langList = getActorLanguagesList(actorJson)
|
||||
assert 'en' in langList
|
||||
assert 'fr' in langList
|
||||
assert 'es' in langList
|
||||
languagesStr = getActorLanguages(actorJson)
|
||||
assert languagesStr == 'en / es / fr'
|
||||
|
||||
|
|
Loading…
Reference in New Issue