@@ -180,6 +180,15 @@ def test_get_index_value_hash_text_list_matches_plain_text(self):
180180
181181 assert plain_hash == text_list_hash
182182
183+ def test_get_index_value_hash_empty_rich_text_is_empty (self ):
184+ """测试空富文本不会生成空字符串哈希"""
185+ converter = DataConverter (TargetType .BITABLE )
186+ rich_text_row = pd .Series ({"ID" : [{"text" : "" , "type" : "text" }]})
187+
188+ hash_value = converter .get_index_value_hash (rich_text_row , "ID" , {"ID" : 1 })
189+
190+ assert hash_value is None
191+
183192 def test_get_index_value_hash_date_string_matches_timestamp (self ):
184193 """测试本地日期字符串和飞书日期时间戳生成相同索引哈希"""
185194 converter = DataConverter (TargetType .BITABLE )
@@ -522,6 +531,32 @@ def test_convert_without_field_types(self):
522531 result = converter .convert_field_value_safe ("test" , "123" , None )
523532 assert result == 123 # 智能识别为数字
524533
534+ def test_convert_multi_segment_text_value (self ):
535+ """测试多段富文本写入文本字段时不会触发 pandas 空值判断异常"""
536+ converter = DataConverter (TargetType .BITABLE )
537+ value = [
538+ {"text" : "李宁少昊" , "type" : "text" },
539+ {"text" : "运动户外专卖店" , "type" : "text" },
540+ ]
541+
542+ result = converter .convert_field_value_safe ("Name" , value , {"Name" : 1 })
543+
544+ assert result == "李宁少昊运动户外专卖店"
545+
546+ def test_convert_multi_value_complex_fields (self ):
547+ """测试多个复杂字段值写入时不会触发 pandas 空值判断异常"""
548+ converter = DataConverter (TargetType .BITABLE )
549+
550+ assert converter .convert_field_value_safe (
551+ "Users" , ["ou_1" , "ou_2" ], {"Users" : 11 }
552+ ) == [{"id" : "ou_1" }, {"id" : "ou_2" }]
553+ assert converter .convert_field_value_safe (
554+ "Files" , ["file_1" , "file_2" ], {"Files" : 17 }
555+ ) == [{"file_token" : "file_1" }, {"file_token" : "file_2" }]
556+ assert converter .convert_field_value_safe (
557+ "Links" , ["rec_1" , "rec_2" ], {"Links" : 18 }
558+ ) == ["rec_1" , "rec_2" ]
559+
525560
526561class TestSimpleConvertValue :
527562 """简单值转换测试(电子表格模式)"""
@@ -683,6 +718,24 @@ def test_df_to_records_preserves_complex_text_value(self):
683718
684719 assert records == [{"fields" : {"Name" : "李宁少昊运动户外专卖店" }}]
685720
721+ def test_df_to_records_preserves_multi_segment_text_value (self ):
722+ """测试多段富文本写入不会被 pandas 空值判断中断"""
723+ converter = DataConverter (TargetType .BITABLE )
724+ df = pd .DataFrame (
725+ {
726+ "Name" : [
727+ [
728+ {"text" : "李宁少昊" , "type" : "text" },
729+ {"text" : "运动户外专卖店" , "type" : "text" },
730+ ],
731+ ]
732+ }
733+ )
734+
735+ records = converter .df_to_records (df , {"Name" : 1 })
736+
737+ assert records == [{"fields" : {"Name" : "李宁少昊运动户外专卖店" }}]
738+
686739 def test_df_to_records_sheet_raises_error (self , sample_dataframe ):
687740 """测试电子表格模式调用 df_to_records 抛出错误"""
688741 converter = DataConverter (TargetType .SHEET )
0 commit comments