<s> from __future__ import unicode_literals <EOL> import frappe <EOL> import unittest <EOL> from frappe import _ <EOL> class TestTranslation ( unittest . TestCase ) : <EOL> def tearDown ( self ) : <EOL> frappe . local . lang = '<STR_LIT>' <EOL> frappe . local . lang_full_dict = None <EOL> def test_doctype ( self ) : <EOL> translation_data = get_translation_data ( ) <EOL> for key , val in translation_data . items ( ) : <EOL> frappe . local . lang = key <EOL> frappe . local . lang_full_dict = None <EOL> translation = create_translation ( key , val ) <EOL> self . assertEquals ( _ ( translation . source_name ) , val [ <NUM_LIT:1> ] ) <EOL> frappe . delete_doc ( '<STR_LIT>' , translation . name ) <EOL> frappe . local . lang_full_dict = None <EOL> self . assertEquals ( _ ( translation . source_name ) , val [ <NUM_LIT:0> ] ) <EOL> def get_translation_data ( ) : <EOL> html_source_data = """<STR_LIT>""" <EOL> html_translated_data = """<STR_LIT>""" <EOL> return { '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ html_source_data , html_translated_data ] } <EOL> def create_translation ( key , val ) : <EOL> translation = frappe . new_doc ( '<STR_LIT>' ) <EOL> translation . language_code = key <EOL> translation . source_name = val [ <NUM_LIT:0> ] <EOL> translation . target_name = val [ <NUM_LIT:1> ] <EOL> translation . save ( ) <EOL> return translation </s>
