@@ -20,15 +20,8 @@ def test_validation_passes_with_all_required_fields(self) -> None:
2020 template ._dim_names = ("inline" , "crossline" , "time" )
2121 template ._coord_names = ("cdp_x" , "cdp_y" )
2222
23- # SegySpec with all required fields
24- spec = get_segy_standard (1.0 )
25- header_fields = [
26- HeaderField (name = "inline" , byte = 189 , format = "int32" ),
27- HeaderField (name = "crossline" , byte = 193 , format = "int32" ),
28- HeaderField (name = "cdp_x" , byte = 181 , format = "int32" ),
29- HeaderField (name = "cdp_y" , byte = 185 , format = "int32" ),
30- ]
31- segy_spec = spec .customize (trace_header_fields = header_fields )
23+ # Use base SEG-Y standard which includes coordinate_scalar at byte 71
24+ segy_spec = get_segy_standard (1.0 )
3225
3326 # Should not raise any exception
3427 _validate_spec_in_template (segy_spec , template )
@@ -57,3 +50,25 @@ def test_validation_fails_with_missing_fields(self) -> None:
5750 assert "custom_coord_x" in error_message
5851 assert "custom_coord_y" in error_message
5952 assert "CustomTemplate" in error_message
53+
54+ def test_validation_fails_with_missing_coordinate_scalar (self ) -> None :
55+ """Test that validation fails when coordinate_scalar is missing, even with all other fields."""
56+ template = MagicMock ()
57+ template .name = "TestTemplate"
58+ template ._dim_names = ("inline" , "crossline" , "time" )
59+ template ._coord_names = ("cdp_x" , "cdp_y" )
60+
61+ # Create SegySpec with all standard fields except coordinate_scalar
62+ spec = get_segy_standard (1.0 )
63+ # Remove coordinate_scalar from the standard fields
64+ standard_fields = [field for field in spec .trace .header .fields if field .name != "coordinate_scalar" ]
65+ standard_fields .append (HeaderField (name = "not_coordinate_scalar" , byte = 71 , format = "int16" ))
66+ segy_spec = spec .customize (trace_header_fields = standard_fields )
67+
68+ # Should raise ValueError for missing coordinate_scalar
69+ with pytest .raises (ValueError , match = r"Required fields.*not found in.*segy_spec" ) as exc_info :
70+ _validate_spec_in_template (segy_spec , template )
71+
72+ error_message = str (exc_info .value )
73+ assert "coordinate_scalar" in error_message
74+ assert "TestTemplate" in error_message
0 commit comments