#NEWLINE# def build_case_structures( self , test_name ) : #NEWLINE# #INDENT# test = self . _get_test ( test_name ) #NEWLINE# case_structures = [ ] #NEWLINE# indices = { case : [ ] for case in self . ALL_CASES } #NEWLINE# for ( i , subcase ) in enumerate ( test . get ( 'subcases' , [ ] ) ) : #NEWLINE# #INDENT# indices [ subcase [ 0 ] ] . append ( CaseIndex ( related_structure = CaseStructure ( attrs = { #NEWLINE# #INDENT# 'create' : False , #NEWLINE# 'owner_id' : ( self . user . user_id if ( subcase [ 1 ] in test . get ( 'owned' , [ ] ) ) else uuid . uuid4 ( ) . hex ) , #NEWLINE# 'close' : ( subcase [ 1 ] in test . get ( 'closed' , [ ] ) ) , #NEWLINE# #UNINDENT# } , case_id = subcase [ 1 ] ) , relationship = 'child' , identifier = 'child_{}' . format ( i ) ) ) #NEWLINE# #UNINDENT# for ( i , extension ) in enumerate ( test . get ( 'extensions' , [ ] ) ) : #NEWLINE# #INDENT# indices [ extension [ 0 ] ] . append ( CaseIndex ( related_structure = CaseStructure ( attrs = { #NEWLINE# #INDENT# 'create' : False , #NEWLINE# 'owner_id' : ( self . user . user_id if ( extension [ 1 ] in test . get ( 'owned' , [ ] ) ) else uuid . uuid4 ( ) . hex ) , #NEWLINE# 'close' : ( extension [ 1 ] in test . get ( 'closed' , [ ] ) ) , #NEWLINE# #UNINDENT# } , case_id = extension [ 1 ] ) , relationship = 'extension' , identifier = 'extension_{}' . format ( i ) ) ) #NEWLINE# #UNINDENT# for case in self . ALL_CASES : #NEWLINE# #INDENT# case_structures . append ( CaseStructure ( attrs = { #NEWLINE# #INDENT# 'create' : True , #NEWLINE# 'owner_id' : ( self . user . user_id if ( case in test . get ( 'owned' , [ ] ) ) else uuid . uuid4 ( ) . hex ) , #NEWLINE# 'close' : ( case in test . get ( 'closed' , [ ] ) ) , #NEWLINE# #UNINDENT# } , case_id = case , indices = indices [ case ] ) ) #NEWLINE# #UNINDENT# self . factory . create_or_update_cases ( case_structures )