#NEWLINE# def test_indices( self ) : #NEWLINE# #INDENT# parents = [ 'catelyn' , 'ned' , 'cersei' , 'jaimie' ] #NEWLINE# index_structure = { #NEWLINE# #INDENT# 'bran' : [ { #NEWLINE# #INDENT# 'identifier' : 'mom' , #NEWLINE# 'referenced_id' : 'catelyn' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'identifier' : 'dad' , #NEWLINE# 'referenced_id' : 'ned' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'myrcella' : [ { #NEWLINE# #INDENT# 'identifier' : 'mom' , #NEWLINE# 'referenced_id' : 'cersei' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'identifier' : 'dad' , #NEWLINE# 'referenced_id' : 'jaimie' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# sync_log = SyncLog ( cases_on_phone = [ CaseState ( case_id = 'bran' , indices = [ CommCareCaseIndex ( ** args ) for args in index_structure [ 'bran' ] ] ) , CaseState ( case_id = 'myrcella' , indices = [ CommCareCaseIndex ( ** args ) for args in index_structure [ 'myrcella' ] ] ) ] , dependent_cases_on_phone = [ CaseState ( case_id = parent ) for parent in parents ] ) #NEWLINE# migrated = SimplifiedSyncLog . from_other_format ( sync_log ) #NEWLINE# for ( case_id , indices ) in index_structure . items ( ) : #NEWLINE# #INDENT# self . assertTrue ( ( case_id in migrated . index_tree . indices ) ) #NEWLINE# for index in indices : #NEWLINE# #INDENT# self . assertEqual ( index [ 'referenced_id' ] , migrated . index_tree . indices [ case_id ] [ index [ 'identifier' ] ] ) #NEWLINE# #UNINDENT# #UNINDENT# for parent in parents : #NEWLINE# #INDENT# self . assertTrue ( ( parent in migrated . case_ids_on_phone ) ) #NEWLINE# self . assertTrue ( ( parent in migrated . dependent_case_ids_on_phone ) )