#NEWLINE# def test_multiple_write_export_instance_calls( self ) : #NEWLINE# #INDENT# '\n        Confirm that calling _write_export_instance() multiple times\n        (as part of a bulk export) works as expected.\n        ' #NEWLINE# export_instances = [ FormExportInstance ( tables = [ TableConfiguration ( label = 'My table' , selected = True , path = [ ] , columns = [ ExportColumn ( label = 'Q3' , item = ScalarItem ( path = [ PathNode ( name = 'form' ) , PathNode ( name = 'q3' ) ] ) , selected = True ) ] ) ] ) , FormExportInstance ( tables = [ TableConfiguration ( label = 'My other table' , selected = True , path = [ PathNode ( name = 'form' , is_repeat = False ) , PathNode ( name = 'q2' , is_repeat = False ) ] , columns = [ ExportColumn ( label = 'Q4' , item = ScalarItem ( path = [ PathNode ( name = 'form' ) , PathNode ( name = 'q2' ) , PathNode ( name = 'q4' ) ] ) , selected = True ) ] ) ] ) ] #NEWLINE# writer = _Writer ( get_writer ( Format . JSON ) ) #NEWLINE# with writer . open ( export_instances ) : #NEWLINE# #INDENT# _write_export_instance ( writer , export_instances [ 0 ] , self . docs ) #NEWLINE# _write_export_instance ( writer , export_instances [ 1 ] , self . docs ) #NEWLINE# #UNINDENT# with ExportFile ( writer . path , writer . format ) as export : #NEWLINE# #INDENT# self . assertEqual ( json . loads ( writer ) , { #NEWLINE# #INDENT# 'My table' : { #NEWLINE# #INDENT# 'headers' : [ 'Q3' ] , #NEWLINE# 'rows' : [ [ 'baz' ] , [ 'bop' ] ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'My other table' : { #NEWLINE# #INDENT# 'headers' : [ 'Q4' ] , #NEWLINE# 'rows' : [ [ 'bar' ] , [ 'boop' ] ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } )