<s> import os <EOL> from django . core . files . storage import get_storage_class <EOL> from django . utils . dateparse import parse_datetime <EOL> from onadata . apps . viewer . models . data_dictionary import DataDictionary <EOL> from onadata . apps . viewer . models . export import Export <EOL> from onadata . libs . utils . export_tools import generate_export <EOL> from test_base import TestBase <EOL> class TestExport ( TestBase ) : <EOL> def setUp ( self ) : <EOL> self . _create_user_and_login ( ) <EOL> self . fixture_dir = os . path . join ( <EOL> self . this_directory , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . _submission_time = parse_datetime ( '<STR_LIT>' ) <EOL> def test_csv_export_url ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def test_csv_export_output ( self ) : <EOL> path = os . path . join ( self . fixture_dir , '<STR_LIT>' ) <EOL> self . _publish_xls_file_and_set_xform ( path ) <EOL> path = os . path . join ( self . fixture_dir , '<STR_LIT>' ) <EOL> self . _make_submission ( <EOL> path , forced_submission_time = self . _submission_time ) <EOL> export = generate_export ( Export . CSV_EXPORT , '<STR_LIT>' , self . user . username , <EOL> '<STR_LIT>' ) <EOL> storage = get_storage_class ( ) ( ) <EOL> self . assertTrue ( storage . exists ( export . filepath ) ) <EOL> path , ext = os . path . splitext ( export . filename ) <EOL> self . assertEqual ( ext , '<STR_LIT>' ) <EOL> with open ( os . path . join ( <EOL> self . fixture_dir , '<STR_LIT>' ) ) as f1 : <EOL> with storage . open ( export . filepath ) as f2 : <EOL> expected_content = f1 . read ( ) <EOL> actual_content = f2 . read ( ) <EOL> self . assertEquals ( actual_content , expected_content ) <EOL> def test_csv_nested_repeat_output ( self ) : <EOL> path = os . path . join ( self . fixture_dir , '<STR_LIT>' ) <EOL> self . _publish_xls_file ( path ) <EOL> path = os . path . join ( self . fixture_dir , '<STR_LIT>' ) <EOL> self . _make_submission ( <EOL> path , forced_submission_time = self . _submission_time ) <EOL> self . maxDiff = None <EOL> dd = DataDictionary . objects . all ( ) [ <NUM_LIT:0> ] <EOL> xpaths = [ <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u'<STR_LIT>' <EOL> ] <EOL> self . assertEquals ( dd . xpaths ( repeat_iterations = <NUM_LIT:2> ) , xpaths ) <EOL> export = generate_export ( Export . CSV_EXPORT , '<STR_LIT>' , self . user . username , <EOL> '<STR_LIT>' ) <EOL> storage = get_storage_class ( ) ( ) <EOL> self . assertTrue ( storage . exists ( export . filepath ) ) <EOL> path , ext = os . path . splitext ( export . filename ) <EOL> self . assertEqual ( ext , '<STR_LIT>' ) <EOL> with open ( os . path . join ( self . fixture_dir , '<STR_LIT>' ) ) as f1 : <EOL> with storage . open ( export . filepath ) as f2 : <EOL> expected_content = f1 . read ( ) <EOL> actual_content = f2 . read ( ) <EOL> self . assertEquals ( actual_content , expected_content ) <EOL> def test_dotted_fields_csv_export_output ( self ) : <EOL> path = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . _publish_xls_file_and_set_xform ( path ) <EOL> path = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . _make_submission ( <EOL> path , forced_submission_time = self . _submission_time ) <EOL> export = generate_export ( Export . CSV_EXPORT , '<STR_LIT>' , self . user . username , <EOL> '<STR_LIT>' ) <EOL> storage = get_storage_class ( ) ( ) <EOL> self . assertTrue ( storage . exists ( export . filepath ) ) <EOL> path , ext = os . path . splitext ( export . filename ) <EOL> self . assertEqual ( ext , '<STR_LIT>' ) <EOL> with open ( os . path . join ( <EOL> os . path . dirname ( __file__ ) , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) as f1 : <EOL> with storage . open ( export . filepath ) as f2 : <EOL> expected_content = f1 . read ( ) <EOL> actual_content = f2 . read ( ) <EOL> self . assertEquals ( actual_content , expected_content ) </s>
