@@ -760,3 +760,56 @@ def test_extract_ctas_manifest_paths_cross_bucket_raises(moto_s3_client: "S3Clie
760760
761761 with pytest .raises (InvalidArgumentValue , match = "unexpected bucket" ):
762762 _extract_ctas_manifest_paths (path = f"s3://bucket/{ manifest_key } " )
763+
764+
765+ def test_dynamodb_read_items_with_key_schema (moto_dynamodb_client , moto_dynamodb_table ) -> None :
766+ # Insert items
767+ items = [{"key" : 1 , "value" : "A" }, {"key" : 2 , "value" : "B" }]
768+ wr .dynamodb .put_items (items = items , table_name = moto_dynamodb_table )
769+
770+ # 1. Verify read_items works with key_schema passed
771+ key_schema = [{"AttributeName" : "key" , "KeyType" : "HASH" }]
772+ df = wr .dynamodb .read_items (
773+ table_name = moto_dynamodb_table ,
774+ key_schema = key_schema ,
775+ allow_full_scan = True ,
776+ )
777+ assert len (df ) == 2
778+ assert set (df ["value" ]) == {"A" , "B" }
779+
780+ # 2. Assert DescribeTable is NOT called when key_schema is provided
781+ call = botocore .client .BaseClient ._make_api_call
782+ describe_table_calls = 0
783+
784+ def mock_make_api_call (self , operation_name , kwarg ):
785+ nonlocal describe_table_calls
786+ if operation_name == "DescribeTable" :
787+ describe_table_calls += 1
788+ return call (self , operation_name , kwarg )
789+
790+ with mock .patch ("botocore.client.BaseClient._make_api_call" , new = mock_make_api_call ):
791+ # Call read_items with key_schema
792+ wr .dynamodb .read_items (
793+ table_name = moto_dynamodb_table ,
794+ key_schema = key_schema ,
795+ allow_full_scan = True ,
796+ )
797+ assert describe_table_calls == 0
798+
799+ # Call read_items WITHOUT key_schema
800+ wr .dynamodb .read_items (
801+ table_name = moto_dynamodb_table ,
802+ allow_full_scan = True ,
803+ )
804+ assert describe_table_calls == 1
805+
806+
807+ def test_csv_pandas_mode_append (moto_s3_client : "S3Client" ) -> None :
808+ path = "s3://bucket/test_append.csv"
809+ df1 = pd .DataFrame ({"col" : [1 , 2 , 3 ]})
810+ df2 = pd .DataFrame ({"col" : [4 , 5 , 6 ]})
811+ wr .s3 .to_csv (df = df1 , path = path , index = False )
812+ wr .s3 .to_csv (df = df2 , path = path , index = False , pandas_mode = "a" , header = False )
813+ result = wr .s3 .read_csv (path = path )
814+ assert len (result ) == 6
815+ assert list (result ["col" ]) == [1 , 2 , 3 , 4 , 5 , 6 ]
0 commit comments