@@ -123,10 +123,25 @@ def test_a_long_read_response_is_copied_whole_into_an_artifact(captured):
123123 assert str (files [0 ]) in captured [- 1 ]
124124
125125
126- def test_a_short_response_is_not_captured_nor_its_command (captured ):
127- assert "is not captured at all, its path or command line included" in _paragraph ()
128- hook .process_event (_event ("Bash" , {"command" : "grep 'Alice Martin' a.csv" }, "ok" ))
126+ def test_a_bash_call_under_the_formatted_threshold_is_dropped_whole (captured ):
127+ assert "fewer than 30 characters on a single stream" in _paragraph ()
128+ kept = _number_before ("characters on a single stream" )
129+ command = "grep 'Alice Martin' a.csv"
130+ for stream in ("stdout" , "stderr" ):
131+ hook .process_event (
132+ _event ("Bash" , {"command" : command }, {stream : "x" * (kept - 1 )})
133+ )
134+ hook .process_event (_event ("Bash" , {"command" : command }, {stream : "" }))
129135 assert captured == []
136+ hook .process_event (_event ("Bash" , {"command" : command }, {"stdout" : "x" * kept }))
137+ assert len (captured ) == 1 and "Alice Martin" in captured [- 1 ]
138+
139+
140+ def test_a_one_character_edit_is_captured_with_its_path (captured ):
141+ assert "so an edit is almost always" in _paragraph ()
142+ response = {"filePath" : "/p/clients.csv" , "oldString" : "x" , "newString" : "y" }
143+ hook .process_event (_event ("Edit" , {"file_path" : "/p/clients.csv" }, response ))
144+ assert "/p/clients.csv" in captured [- 1 ]
130145
131146
132147def test_an_edit_keeps_before_and_after_and_not_the_previous_file (captured ):
@@ -142,14 +157,20 @@ def test_an_edit_keeps_before_and_after_and_not_the_previous_file(captured):
142157 assert "Bob Durand" not in captured [- 1 ]
143158
144159
145- @pytest .mark .parametrize ("tool" , ["Write" , "MultiEdit" ])
146- def test_a_write_or_multiedit_response_is_stored_whole (captured , tool ):
147- assert "a Write or MultiEdit response is stored as its whole JSON" in _paragraph ()
160+ _WHOLE_JSON_RESPONSES = {
161+ "Write" : {"type" : "update" , "content" : "Alice Martin, 12 rue des Lilas" },
162+ "MultiEdit" : {"edits" : [{"old_string" : "Alice" , "new_string" : "Alice Martin" }]},
163+ "NotebookEdit" : {"new_source" : "Alice Martin, 12 rue des Lilas" , "cell_id" : "c1" },
164+ }
165+
166+
167+ @pytest .mark .parametrize ("tool" , sorted (_WHOLE_JSON_RESPONSES ))
168+ def test_a_write_multiedit_or_notebookedit_response_is_stored_whole (captured , tool ):
169+ assert "NotebookEdit response is stored as its whole JSON" in _paragraph ()
148170 response = {
149- "type" : "update" ,
150171 "filePath" : "/p/clients.csv" ,
151- "content" : "Alice Martin, 12 rue des Lilas, diabetic" ,
152172 "originalFile" : "Bob Durand, 3 rue Haute, asthmatic" ,
173+ ** _WHOLE_JSON_RESPONSES [tool ],
153174 }
154175 hook .process_event (_event (tool , {"file_path" : "/p/clients.csv" }, response ))
155176 assert "Alice Martin" in captured [- 1 ] and "Bob Durand" in captured [- 1 ]
0 commit comments