def test_lang_good_and_bad_code(self): option = search.LangOption() self.assertRaises(ValidationError, option.validate, ['en', 'foo'])
def test_lang_multi_list(self): option = search.LangOption() value = option.validate(['en', 'es', 'fr']) self.assertEqual(['en', 'es', 'fr'], value)
def test_lang_bad_type(self): option = search.LangOption() self.assertRaises(ValidationError, option.validate, {})
def test_lang_str(self): option = search.LangOption() value = option.validate('en') self.assertEqual(['en'], value)
def test_lang_default(self): option = search.LangOption(default=['en']) value = option.validate(None) self.assertEqual(['en'], value)
def test_lang_no_default_none(self): option = search.LangOption() value = option.validate(None) self.assertIsNone(value)
def test_lang_missing_and_with_territory(self): option = search.LangOption() value = option.validate(['zh_CN', 'pt_BR', 'fr']) self.assertEqual(['fr', 'en', 'pt'], value)
def test_lang_good_and_bad_code(self): option = search.LangOption() value = option.validate(['en', 'foo']) self.assertEqual(['en'], value)