@@ -170,3 +170,32 @@ def test_transformers_multimodal_type_adapter_format_input_chat_missing_type_key
170
170
171
171
with pytest .raises (ValueError , match = "Each item in the content list must be a dictionary with a 'type' key" ):
172
172
adapter .format_input (chat_prompt )
173
+
174
+
175
+ def test_transformers_multimodal_type_adapter_format_input_invalid_content_type (adapter ):
176
+ chat_prompt = Chat (messages = [
177
+ {"role" : "user" , "content" : 42 } # Invalid content type (integer)
178
+ ])
179
+
180
+ with pytest .raises (ValueError , match = "Invalid content type" ):
181
+ adapter .format_input (chat_prompt )
182
+
183
+ # Test with another invalid type
184
+ chat_prompt = Chat (messages = [
185
+ {"role" : "user" , "content" : {"invalid" : "dict" }} # Invalid content type (dict not in list)
186
+ ])
187
+
188
+ with pytest .raises (ValueError , match = "Invalid content type" ):
189
+ adapter .format_input (chat_prompt )
190
+
191
+
192
+ def test_transformers_multimodal_type_adapter_format_asset_for_template_invalid_type (adapter ):
193
+ class MockUnsupportedAsset :
194
+ pass
195
+
196
+ # This test requires accessing the private method directly since the error
197
+ # would normally be caught earlier in the validation chain
198
+ unsupported_asset = MockUnsupportedAsset ()
199
+
200
+ with pytest .raises (ValueError , match = "Assets must be of type `Image`, `Video` or `Audio`" ):
201
+ adapter ._format_asset_for_template (unsupported_asset )
0 commit comments