File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,28 @@ def test_normalize_extension_create_input_uses_metadata_not_file_prefix(
187187 assert exc_info .value .original_error is None
188188
189189
190+ def test_normalize_extension_create_input_uses_default_not_file_prefix_when_metadata_invalid (
191+ tmp_path , monkeypatch : pytest .MonkeyPatch
192+ ):
193+ params = CreateExtensionParams (name = "dir-extension" , file_path = tmp_path )
194+ monkeypatch .setattr (
195+ extension_create_utils ,
196+ "EXTENSION_OPERATION_METADATA" ,
197+ SimpleNamespace (
198+ missing_file_message_prefix = "Custom extension missing prefix" ,
199+ not_file_message_prefix = 123 ,
200+ ),
201+ )
202+
203+ with pytest .raises (
204+ HyperbrowserError ,
205+ match = "Extension file path must point to a file:" ,
206+ ) as exc_info :
207+ normalize_extension_create_input (params )
208+
209+ assert exc_info .value .original_error is None
210+
211+
190212def test_normalize_extension_create_input_rejects_control_character_path ():
191213 params = CreateExtensionParams (
192214 name = "bad-extension" ,
Original file line number Diff line number Diff line change @@ -149,6 +149,33 @@ def test_normalize_upload_file_input_uses_default_missing_prefix_when_metadata_i
149149 assert exc_info .value .original_error is None
150150
151151
152+ def test_normalize_upload_file_input_uses_default_not_file_prefix_when_metadata_invalid (
153+ tmp_path : Path ,
154+ monkeypatch : pytest .MonkeyPatch ,
155+ ):
156+ monkeypatch .setattr (
157+ session_upload_utils ,
158+ "SESSION_OPERATION_METADATA" ,
159+ type (
160+ "_Metadata" ,
161+ (),
162+ {
163+ "upload_missing_file_message_prefix" : "Custom missing prefix" ,
164+ "upload_not_file_message_prefix" : 123 ,
165+ "upload_open_file_error_prefix" : "Custom open prefix" ,
166+ },
167+ )(),
168+ )
169+
170+ with pytest .raises (
171+ HyperbrowserError ,
172+ match = "Upload file path must point to a file:" ,
173+ ) as exc_info :
174+ normalize_upload_file_input (tmp_path )
175+
176+ assert exc_info .value .original_error is None
177+
178+
152179def test_normalize_upload_file_input_returns_open_file_like_object ():
153180 file_obj = io .BytesIO (b"content" )
154181
You can’t perform that action at this time.
0 commit comments