@@ -18,7 +18,7 @@ use common::test_utils::{
1818} ;
1919use common:: transport:: { run_communication_test, CommunicationChannel , TransportType } ;
2020use common:: TestServer ;
21- use kallichore_api:: models:: { InterruptMode , NewSession , VarAction , VarActionType } ;
21+ use kallichore_api:: models:: { InterruptMode , NewSession , SessionMode , VarAction , VarActionType } ;
2222use kallichore_api:: NewSessionResponse ;
2323use kcshared:: jupyter_message:: { JupyterChannel , JupyterMessage , JupyterMessageHeader } ;
2424use kcshared:: websocket_message:: WebsocketMessage ;
@@ -283,6 +283,8 @@ async fn test_multiple_kernel_sessions() {
283283 username : "testuser" . to_string ( ) ,
284284 input_prompt : "In [{}]: " . to_string ( ) ,
285285 continuation_prompt : " ...: " . to_string ( ) ,
286+ notebook_uri : None ,
287+ session_mode : SessionMode :: Console ,
286288 argv : vec ! [
287289 python_cmd. clone( ) ,
288290 "-m" . to_string( ) ,
@@ -395,7 +397,7 @@ async fn run_python_kernel_test_domain_socket(python_cmd: &str) {
395397
396398 // Create session via HTTP over Unix socket
397399 let session_request = format ! (
398- r#"{{"session_id": "{}", "display_name": "Test Session", "language": "python", "username": "testuser", "input_prompt": "In [{{}}]: ", "continuation_prompt": " ...: ", "argv": ["{}", "-m", "ipykernel", "-f", "{{connection_file}}"], "working_directory": "/tmp", "env": [], "connection_timeout": 60, "interrupt_mode": "message", "protocol_version": "5.3", "run_in_shell": false}}"# ,
400+ r#"{{"session_id": "{}", "display_name": "Test Session", "language": "python", "username": "testuser", "input_prompt": "In [{{}}]: ", "continuation_prompt": " ...: ", "argv": ["{}", "-m", "ipykernel", "-f", "{{connection_file}}"], "working_directory": "/tmp", "env": [], "connection_timeout": 60, "interrupt_mode": "message", "protocol_version": "5.3", "run_in_shell": false, "session_mode": "console" }}"# ,
399401 session_id, python_cmd
400402 ) ;
401403
@@ -1380,6 +1382,8 @@ async fn test_kernel_starts_with_bad_shell_env_var() {
13801382 username : "testuser" . to_string ( ) ,
13811383 input_prompt : "In [{}]: " . to_string ( ) ,
13821384 continuation_prompt : " ...: " . to_string ( ) ,
1385+ notebook_uri : None ,
1386+ session_mode : SessionMode :: Console ,
13831387 argv : vec ! [
13841388 python_cmd. clone( ) ,
13851389 "-m" . to_string( ) ,
@@ -1397,7 +1401,7 @@ async fn test_kernel_starts_with_bad_shell_env_var() {
13971401 action: VarActionType :: Replace ,
13981402 name: "SHELL" . to_string( ) ,
13991403 value: "/non/existent/shell" . to_string( ) ,
1400- }
1404+ } ,
14011405 ] ,
14021406 connection_timeout : Some ( 15 ) ,
14031407 interrupt_mode : InterruptMode :: Message ,
@@ -1444,8 +1448,14 @@ async fn test_kernel_starts_with_bad_shell_env_var() {
14441448 . expect ( "Failed to get sessions list" ) ;
14451449
14461450 let kallichore_api:: ListSessionsResponse :: ListOfActiveSessions ( session_list) = sessions;
1447- let session_found = session_list. sessions . iter ( ) . any ( |s| s. session_id == session_id) ;
1448- assert ! ( session_found, "Session should be in the active sessions list" ) ;
1451+ let session_found = session_list
1452+ . sessions
1453+ . iter ( )
1454+ . any ( |s| s. session_id == session_id) ;
1455+ assert ! (
1456+ session_found,
1457+ "Session should be in the active sessions list"
1458+ ) ;
14491459
14501460 println ! ( "Test passed: Kernel started successfully despite bad SHELL environment variable" ) ;
14511461
@@ -1493,7 +1503,7 @@ async fn test_run_in_shell_functionality() {
14931503 shell_env : Option < & str > ,
14941504 ) -> String {
14951505 let session_id = format ! ( "test-shell-{}-{}" , test_name, Uuid :: new_v4( ) ) ;
1496-
1506+
14971507 // Create a custom session with the desired shell configuration
14981508 let mut env_vars = vec ! [ ] ;
14991509
@@ -1513,6 +1523,8 @@ async fn test_run_in_shell_functionality() {
15131523 username : "testuser" . to_string ( ) ,
15141524 input_prompt : "In [{}]: " . to_string ( ) ,
15151525 continuation_prompt : " ...: " . to_string ( ) ,
1526+ session_mode : SessionMode :: Console ,
1527+ notebook_uri : None ,
15161528 argv : vec ! [
15171529 python_cmd. to_string( ) ,
15181530 "-m" . to_string( ) ,
@@ -1531,7 +1543,7 @@ async fn test_run_in_shell_functionality() {
15311543 run_in_shell : Some ( run_in_shell) ,
15321544 } ;
15331545
1534- println ! ( "Creating session '{}' with run_in_shell={}, shell_env={:?}" ,
1546+ println ! ( "Creating session '{}' with run_in_shell={}, shell_env={:?}" ,
15351547 test_name, run_in_shell, shell_env) ;
15361548
15371549 // Create the session
@@ -1579,7 +1591,7 @@ async fn test_run_in_shell_functionality() {
15791591 . unwrap ( )
15801592 . join ( "tests" )
15811593 . join ( "shell_test.py" ) ;
1582-
1594+
15831595 let test_code = format ! (
15841596 r#"
15851597import subprocess
@@ -1591,12 +1603,12 @@ expected_mode = "{}"
15911603
15921604try:
15931605 result = subprocess.run([
1594- sys.executable,
1606+ sys.executable,
15951607 r"{}",
15961608 test_marker,
15971609 expected_mode
15981610 ], capture_output=True, text=True, timeout=10)
1599-
1611+
16001612 if result.returncode == 0:
16011613 print(result.stdout)
16021614 else:
@@ -1719,40 +1731,40 @@ except Exception as e:
17191731 session_id
17201732 }
17211733
1722- // Test 1: run_in_shell = false (default behavior)
1734+ // Test 1: run_in_shell = false (default behavior)
17231735 let session_1 = test_shell_behavior_via_kernel (
1724- & client,
1736+ & client,
17251737 & server,
1726- & python_cmd,
1727- "no-shell" ,
1728- false ,
1738+ & python_cmd,
1739+ "no-shell" ,
1740+ false ,
17291741 None
17301742 ) . await ;
17311743
17321744 // Test 2: run_in_shell = true with default shell
17331745 let session_2 = test_shell_behavior_via_kernel (
1734- & client,
1746+ & client,
17351747 & server,
1736- & python_cmd,
1737- "default-shell" ,
1738- true ,
1748+ & python_cmd,
1749+ "default-shell" ,
1750+ true ,
17391751 None
17401752 ) . await ;
17411753
17421754 // Test 3: run_in_shell = true with bash shell
17431755 let session_3 = test_shell_behavior_via_kernel (
1744- & client,
1756+ & client,
17451757 & server,
1746- & python_cmd,
1747- "bash-shell" ,
1748- true ,
1758+ & python_cmd,
1759+ "bash-shell" ,
1760+ true ,
17491761 Some ( "/bin/bash" )
17501762 ) . await ;
17511763
17521764 // Clean up all sessions
17531765 for ( session_id, name) in [
17541766 ( session_1, "no-shell" ) ,
1755- ( session_2, "default-shell" ) ,
1767+ ( session_2, "default-shell" ) ,
17561768 ( session_3, "bash-shell" ) ,
17571769 ] {
17581770 println ! ( "Deleting session '{}'..." , name) ;
0 commit comments