# Path: randtalkbot/i18n.py
# def get_languages_names(codes):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         str: Comma-separated list of languages' names.
#     """
#     names = map(_get_language_name, codes)
#     return ', '.join(names)
# 
# def get_languages_codes(names):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         list<str>: Deduplicated list of languages' codes.
#     """
#     names = ''.join([c for c in names if c not in QUOTES])
# 
#     if names.strip().lower() in SAME_LANGUAGE_NAMES:
#         return ['same']
# 
#     names = [name.strip() for name in names.split(',')]
#     compact_names = filter(bool, names)
#     languages_codes = map(_get_language_code, compact_names)
#     unique_languages_codes = _get_deduplicated(languages_codes)
#     return unique_languages_codes
# 
# def get_translation(languages):
#     if not languages:
#         languages = ['en']
# 
#     try:
#         translation_instance = gettext.translation(
#             'randtalkbot',
#             localedir=LOCALE_DIR,
#             languages=languages,
#             )
#     except OSError:
#         translation_instance = gettext.translation(
#             'randtalkbot',
#             localedir=LOCALE_DIR,
#             languages=['en'],
#             )
# 
#     return translation_instance.gettext
# 
# class LanguageNotFoundError(Exception):
#     def __init__(self, name):
#         super(LanguageNotFoundError, self).__init__('Language \"{0}\" wasn\'t found.'.format(name))
#         self.name = name


import unittest
from unittest.mock import call, patch
from randtalkbot.i18n import get_languages_names, get_languages_codes, get_translation, \
    LanguageNotFoundError
class TestI18n(unittest.TestCase):
    def test_get_languages_names__supported(self):
        self.assertEqual(get_languages_names(['ru']), 'Русский')

    def test_get_languages_names__not_supported(self):
        self.assertEqual(get_languages_names(['aa', 'ru']), 'Afar, Русский')

    def test_get_languages_names__unknown(self):
        with self.assertRaises(LanguageNotFoundError):
            get_languages_names('foo')

    def test_get_languages_codes__ok(self):
        self.assertEqual(get_languages_codes('   Русский  ,AFAR,, enGLIsh,  '), ['ru', 'aa', 'en'])

    def test_get_languages_codes__duplicates(self):
        self.assertEqual(
            get_languages_codes('enGLIsh, Afar, English, aa, rus'),
            ['en', 'aa', 'ru'],
            )

    def test_get_languages_codes__same(self):
        self.assertEqual(get_languages_codes('Не менять языки'), ['same'])

    def test_get_languages_codes__empty(self):
        self.assertEqual(get_languages_codes(''), [])

    def test_get_languages_codes__quotes(self):
        self.assertEqual(get_languages_codes('“«\"English, German\"”»'), ['en', 'de'])

    def test_get_languages_codes__unknown(self):

# Path: randtalkbot/i18n.py
# def get_languages_names(codes):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         str: Comma-separated list of languages' names.
#     """
#     names = map(_get_language_name, codes)
#     return ', '.join(names)
# 
# def get_languages_codes(names):
#     """Raises:
#         LanguageNotFoundError: If unable to recognize some language.
# 
#     Returns:
#         list<str>: Deduplicated list of languages' codes.
#     """
#     names = ''.join([c for c in names if c not in QUOTES])
# 
#     if names.strip().lower() in SAME_LANGUAGE_NAMES:
#         return ['same']
# 
#     names = [name.strip() for name in names.split(',')]
#     compact_names = filter(bool, names)
#     languages_codes = map(_get_language_code, compact_names)
#     unique_languages_codes = _get_deduplicated(languages_codes)
#     return unique_languages_codes
# 
# def get_translation(languages):
#     if not languages:
#         languages = ['en']
# 
#     try:
#         translation_instance = gettext.translation(
#             'randtalkbot',
#             localedir=LOCALE_DIR,
#             languages=languages,
#             )
#     except OSError:
#         translation_instance = gettext.translation(
#             'randtalkbot',
#             localedir=LOCALE_DIR,
#             languages=['en'],
#             )
# 
#     return translation_instance.gettext
# 
# class LanguageNotFoundError(Exception):
#     def __init__(self, name):
#         super(LanguageNotFoundError, self).__init__('Language \"{0}\" wasn\'t found.'.format(name))
#         self.name = name


# Path: tests/test_i18n.py
import unittest
from unittest.mock import call, patch
from randtalkbot.i18n import get_languages_names, get_languages_codes, get_translation, \
    LanguageNotFoundError

class TestI18n(unittest.TestCase):
    def test_get_languages_names__supported(self):
        self.assertEqual(get_languages_names(['ru']), 'Русский')

    def test_get_languages_names__not_supported(self):
        self.assertEqual(get_languages_names(['aa', 'ru']), 'Afar, Русский')

    def test_get_languages_names__unknown(self):
        with self.assertRaises(LanguageNotFoundError):
            get_languages_names('foo')

    def test_get_languages_codes__ok(self):
        self.assertEqual(get_languages_codes('   Русский  ,AFAR,, enGLIsh,  '), ['ru', 'aa', 'en'])

    def test_get_languages_codes__duplicates(self):
        self.assertEqual(
            get_languages_codes('enGLIsh, Afar, English, aa, rus'),
            ['en', 'aa', 'ru'],
            )

    def test_get_languages_codes__same(self):
        self.assertEqual(get_languages_codes('Не менять языки'), ['same'])

    def test_get_languages_codes__empty(self):
        self.assertEqual(get_languages_codes(''), [])

    def test_get_languages_codes__quotes(self):
        self.assertEqual(get_languages_codes('“«\"English, German\"”»'), ['en', 'de'])

    def test_get_languages_codes__unknown(self):

        with self.assertRaises(LanguageNotFoundError):