@@ -298,15 +298,20 @@ def test_large_dump_s3():
298298 server = ThreadedMotoServer ()
299299 server .start ()
300300 os .environ ["LAMINAR_S3_HOST" ] = "http://localhost:5000"
301-
301+
302302 # Disable checksum validation to fix moto compatibility issues
303303 # Monkey patch the checksum validation to avoid moto checksum mismatch
304304 import botocore .httpchecksum
305+
305306 original_validate = botocore .httpchecksum .StreamingChecksumBody ._validate_checksum
307+
306308 def mock_validate_checksum (self ):
307309 pass # Skip checksum validation for moto
308- botocore .httpchecksum .StreamingChecksumBody ._validate_checksum = mock_validate_checksum
309-
310+
311+ botocore .httpchecksum .StreamingChecksumBody ._validate_checksum = (
312+ mock_validate_checksum
313+ )
314+
310315 try :
311316 # create bucket and put objects
312317 conn = boto3 .client ("s3" , endpoint_url = "http://localhost:5000" )
@@ -356,5 +361,70 @@ def mock_validate_checksum(self):
356361 assert datapackage .descriptor ["count_of_rows" ] == num_rows
357362 finally :
358363 # Restore original checksum validation
359- botocore .httpchecksum .StreamingChecksumBody ._validate_checksum = original_validate
364+ botocore .httpchecksum .StreamingChecksumBody ._validate_checksum = (
365+ original_validate
366+ )
360367 server .stop ()
368+
369+
370+ @mock_aws
371+ @pytest .mark .skipif (TEST_DEV , reason = "test development" )
372+ def test_dump_xlsx_rounding ():
373+ server = ThreadedMotoServer ()
374+ server .start ()
375+ os .environ ["LAMINAR_S3_HOST" ] = "http://localhost:5000"
376+ # create bucket and put objects
377+ conn = boto3 .client ("s3" , endpoint_url = "http://localhost:5000" )
378+ conn .create_bucket (Bucket = "testing_bucket" )
379+ conn .create_bucket (Bucket = "testing_dump_bucket" )
380+ conn .upload_file (
381+ "data/test_floating_point_error2.xlsx" ,
382+ "testing_bucket" ,
383+ "test_floating_point_error2.xlsx" ,
384+ )
385+
386+ flows = [
387+ load (
388+ {
389+ "from" : "s3://testing_bucket/test_floating_point_error2.xlsx" ,
390+ "name" : "res" ,
391+ "format" : "xlsx" ,
392+ "sheet" : 1 ,
393+ "preserve_formatting" : True ,
394+ "adjust_floating_point_error" : True ,
395+ "infer_strategy" : "strings" ,
396+ "cast_strategy" : "strings" ,
397+ }
398+ ),
399+ dump_to_s3 (
400+ {
401+ "prefix" : "test" ,
402+ "force-format" : True ,
403+ "format" : "csv" ,
404+ "save_pipeline_spec" : True ,
405+ "temporal_format_property" : "outputFormat" ,
406+ "bucket_name" : "testing_dump_bucket" ,
407+ "data_manager" : "test" ,
408+ }
409+ ),
410+ ]
411+
412+ rows , datapackage , _ = Flow (* flows ).results ()
413+ body = (
414+ conn .get_object (Bucket = "testing_dump_bucket" , Key = "test/res.csv" )["Body" ]
415+ .read ()
416+ .decode ("utf-8" )
417+ )
418+
419+ assert len (body )
420+ assert len (datapackage .resources ) == 1
421+ csv_file = io .StringIO (body )
422+ reader = csv .reader (csv_file )
423+ dumped_rows = []
424+ for row in reader :
425+ dumped_rows .append (row )
426+
427+ # print(dumped_rows)
428+ assert dumped_rows [34 ][15 ] == rows [0 ][33 ]["ChlaYSI" ]
429+ assert dumped_rows [34 ][15 ] == "1.23"
430+ server .stop ()
0 commit comments