mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Correctly get the disabledLanguages value (it's a ChannelValue, not
GlobalValue) and update the tests to match the new failure string.
This commit is contained in:
parent
9d3c1e6e8b
commit
47d7f5e18b
@ -75,10 +75,10 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
for language in babelfish.available_languages:
|
for language in babelfish.available_languages:
|
||||||
_abbrevs[language] = language
|
_abbrevs[language] = language
|
||||||
|
|
||||||
def _getLang(self, fromLang, toLang):
|
def _getLang(self, fromLang, toLang, chan):
|
||||||
fromLang = self._abbrevs[fromLang.lower()]
|
fromLang = self._abbrevs[fromLang.lower()]
|
||||||
toLang = self._abbrevs[toLang.lower()]
|
toLang = self._abbrevs[toLang.lower()]
|
||||||
disabled = map(str.lower, self.registryValue('disabledLanguages'))
|
disabled = map(str.lower, self.registryValue('disabledLanguages',chan))
|
||||||
if fromLang in disabled:
|
if fromLang in disabled:
|
||||||
fromLang = None
|
fromLang = None
|
||||||
if toLang in disabled:
|
if toLang in disabled:
|
||||||
@ -101,9 +101,9 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
args.pop(1)
|
args.pop(1)
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
(fromLang, toLang) = self._getLang(fromLang, toLang)
|
(fromLang, toLang) = self._getLang(fromLang, toLang, msg.args[0])
|
||||||
if not fromLang or not toLang:
|
if not fromLang or not toLang:
|
||||||
langs = self.registryValue('disabledLanguages')
|
langs = self.registryValue('disabledLanguages', msg.args[0])
|
||||||
irc.error('I do not speak %s.' % utils.commaAndify(langs,
|
irc.error('I do not speak %s.' % utils.commaAndify(langs,
|
||||||
And='or'))
|
And='or'))
|
||||||
return
|
return
|
||||||
@ -128,12 +128,12 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
(fromLang, toLang) = self._getLang(fromLang, toLang)
|
(fromLang, toLang) = self._getLang(fromLang, toLang, msg.args[0])
|
||||||
if fromLang != 'english' and toLang != 'english':
|
if fromLang != 'english' and toLang != 'english':
|
||||||
irc.error('One language must be English.')
|
irc.error('One language must be English.')
|
||||||
return
|
return
|
||||||
if not fromLang or not toLang:
|
if not fromLang or not toLang:
|
||||||
langs = self.registryValue('disabledLanguages')
|
langs = self.registryValue('disabledLanguages', msg.args[0])
|
||||||
irc.error('I do not speak %s.' % utils.commaAndify(langs,
|
irc.error('I do not speak %s.' % utils.commaAndify(langs,
|
||||||
And='or'))
|
And='or'))
|
||||||
return
|
return
|
||||||
@ -157,7 +157,7 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
allowEnglish = privmsgs.getArgs(args, required=0, optional=1)
|
allowEnglish = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
language = random.choice(babelfish.available_languages)
|
language = random.choice(babelfish.available_languages)
|
||||||
disabled = self.registryValue('disabledLanguages')
|
disabled = self.registryValue('disabledLanguages', msg.args[0])
|
||||||
while not allowEnglish and language == 'English' and\
|
while not allowEnglish and language == 'English' and\
|
||||||
language not in disabled:
|
language not in disabled:
|
||||||
language = random.choice(babelfish.available_languages)
|
language = random.choice(babelfish.available_languages)
|
||||||
|
@ -56,13 +56,13 @@ if network:
|
|||||||
dl.set("")
|
dl.set("")
|
||||||
self.assertResponse('translate sp en hola', 'hello')
|
self.assertResponse('translate sp en hola', 'hello')
|
||||||
dl.set("Spanish")
|
dl.set("Spanish")
|
||||||
self.assertRegexp('translate sp en hola', 'forbidden')
|
self.assertRegexp('translate sp en hola', 'do not speak')
|
||||||
self.assertRegexp('translate en sp hola', 'forbidden')
|
self.assertRegexp('translate en sp hola', 'do not speak')
|
||||||
dl.set("Spanish Italian")
|
dl.set("Spanish Italian")
|
||||||
self.assertRegexp('translate sp en hola', 'forbidden')
|
self.assertRegexp('translate sp en hola', 'do not speak')
|
||||||
self.assertRegexp('translate en it hello', 'forbidden')
|
self.assertRegexp('translate en it hello', 'do not speak')
|
||||||
self.assertRegexp('translate en it [translate sp en hola]',
|
self.assertRegexp('translate en it [translate sp en hola]',
|
||||||
'forbidden')
|
'do not speak')
|
||||||
dl.set("")
|
dl.set("")
|
||||||
self.assertResponse('translate en it hello', 'ciao')
|
self.assertResponse('translate en it hello', 'ciao')
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user