#NEWLINE# def test_strings_save2db( self ) : #NEWLINE# #INDENT# 'Test creating source strings from a STRINGS file works' #NEWLINE# source_file = 'test_utf_16.strings' #NEWLINE# trans_file = 'test_translation.strings' #NEWLINE# handler = AppleStringsHandler ( ) #NEWLINE# handler . bind_file ( os . path . join ( os . path . dirname ( __file__ ) , source_file ) ) #NEWLINE# handler . set_language ( self . resource . source_language ) #NEWLINE# handler . parse_file ( is_source = True ) #NEWLINE# r = self . resource #NEWLINE# l = entities . source_language #NEWLINE# handler . bind_resource ( r ) #NEWLINE# handler . save2db ( is_source = True ) #NEWLINE# self . assertEqual ( SourceEntity . objects . filter ( resource = r ) . count ( ) , 4 ) #NEWLINE# self . assertEqual ( len ( Translation . objects . filter ( source_entity__resource = r , language = l ) ) , 4 ) #NEWLINE# handler . bind_file ( os . path . join ( os . path . dirname ( __file__ ) , trans_file ) ) #NEWLINE# l = self . language_ar #NEWLINE# handler . set_language ( l ) #NEWLINE# handler . parse_file ( ) #NEWLINE# entities = 0 #NEWLINE# translations = 0 #NEWLINE# for s in handler . stringset . strings : #NEWLINE# #INDENT# entities += 1 #NEWLINE# if ( s . translation . strip ( ) != '' ) : #NEWLINE# #INDENT# translations += 1 #NEWLINE# #UNINDENT# #UNINDENT# self . assertEqual ( entities , 2 ) #NEWLINE# self . assertEqual ( translations , 2 ) #NEWLINE# handler . save2db ( ) #NEWLINE# self . assertEqual ( SourceEntity . objects . filter ( resource = r ) . count ( ) , 4 ) #NEWLINE# self . assertEqual ( len ( Translation . objects . filter ( source_entity__resource = r , language = l ) ) , 2 ) #NEWLINE# r . delete ( )