@@ -1420,6 +1420,20 @@ def test_optional_extra__mixed_with_required(converter: TabularConverter):
14201420 assert list (result ["guid" ]) == ["guid1" , "guid2" ]
14211421
14221422
1423+ def test_optional_extra__mixed_with_required_missing_column (converter : TabularConverter ):
1424+ """Test that missing required column raises error even with optional_extra present"""
1425+ # Arrange
1426+ data = TabularData (test_table = pd .DataFrame ({"id" : [1 , 2 ], "name" : ["node1" , "node2" ], "guid" : ["guid1" , "guid2" ]}))
1427+ # "missing_col" is required but missing
1428+ col_def = ["name" , "missing_col" , {"optional_extra" : ["guid" , "station" ]}]
1429+
1430+ # Act & Assert
1431+ with pytest .raises (KeyError , match = "missing_col" ):
1432+ converter ._parse_col_def (
1433+ data = data , table = "test_table" , col_def = col_def , table_mask = None , extra_info = None , allow_missing = False
1434+ )
1435+
1436+
14231437def test_optional_extra__in_extra_info (converter : TabularConverter ):
14241438 """Test that optional_extra works correctly with _handle_extra_info"""
14251439 # Arrange
@@ -1444,6 +1458,23 @@ def test_optional_extra__in_extra_info(converter: TabularConverter):
14441458 assert "station" not in extra_info [200 ]
14451459
14461460
1461+ def test_optional_extra__empty_list_with_extra_info (converter : TabularConverter ):
1462+ """Test that empty optional_extra list results in no updates to extra_info"""
1463+ # Arrange
1464+ data = TabularData (test_table = pd .DataFrame ({"id" : [1 , 2 ], "name" : ["node1" , "node2" ], "guid" : ["guid1" , "guid2" ]}))
1465+ uuids = np .array ([100 , 200 ])
1466+ extra_info : ExtraInfo = {}
1467+ col_def : dict [str , list [str ]] = {"optional_extra" : []}
1468+
1469+ # Act
1470+ converter ._handle_extra_info (
1471+ data = data , table = "test_table" , col_def = col_def , uuids = uuids , table_mask = None , extra_info = extra_info
1472+ )
1473+
1474+ # Assert
1475+ assert len (extra_info ) == 0
1476+
1477+
14471478def test_optional_extra__all_missing_no_extra_info (converter : TabularConverter ):
14481479 """Test that when all optional columns are missing, no extra_info entries are created"""
14491480 # Arrange
0 commit comments