@@ -440,55 +440,55 @@ def test_validate_redirection_syntax(executor):
440
440
def test_create_shell_command (executor ):
441
441
"""Test shell command creation with various input combinations"""
442
442
# Test basic command
443
- assert executor ._create_shell_command (["echo" , "hello" ]) == "echo hello"
443
+ assert executor .preprocessor . create_shell_command (["echo" , "hello" ]) == "echo hello"
444
444
445
445
# Test command with space-only argument
446
- assert executor ._create_shell_command (["echo" , " " ]) == "echo ' '"
446
+ assert executor .preprocessor . create_shell_command (["echo" , " " ]) == "echo ' '"
447
447
448
448
# Test command with wildcards
449
- assert executor ._create_shell_command (["ls" , "*.txt" ]) == "ls '*.txt'"
449
+ assert executor .preprocessor . create_shell_command (["ls" , "*.txt" ]) == "ls '*.txt'"
450
450
451
451
# Test command with special characters
452
452
assert (
453
- executor ._create_shell_command (["echo" , "hello;" , "world" ])
453
+ executor .preprocessor . create_shell_command (["echo" , "hello;" , "world" ])
454
454
== "echo 'hello;' world"
455
455
)
456
456
457
457
# Test empty command
458
- assert executor ._create_shell_command ([]) == ""
458
+ assert executor .preprocessor . create_shell_command ([]) == ""
459
459
460
460
461
461
def test_preprocess_command (executor ):
462
462
"""Test command preprocessing for pipeline handling"""
463
463
# Test basic command
464
- assert executor ._preprocess_command (["ls" ]) == ["ls" ]
464
+ assert executor .preprocessor . preprocess_command (["ls" ]) == ["ls" ]
465
465
466
466
# Test command with separate pipe
467
- assert executor ._preprocess_command (["ls" , "|" , "grep" , "test" ]) == [
467
+ assert executor .preprocessor . preprocess_command (["ls" , "|" , "grep" , "test" ]) == [
468
468
"ls" ,
469
469
"|" ,
470
470
"grep" ,
471
471
"test" ,
472
472
]
473
473
474
474
# Test command with attached pipe
475
- assert executor ._preprocess_command (["ls|" , "grep" , "test" ]) == [
475
+ assert executor .preprocessor . preprocess_command (["ls|" , "grep" , "test" ]) == [
476
476
"ls" ,
477
477
"|" ,
478
478
"grep" ,
479
479
"test" ,
480
480
]
481
481
482
482
# Test command with special operators
483
- assert executor ._preprocess_command (["echo" , "hello" , "&&" , "ls" ]) == [
483
+ assert executor .preprocessor . preprocess_command (["echo" , "hello" , "&&" , "ls" ]) == [
484
484
"echo" ,
485
485
"hello" ,
486
486
"&&" ,
487
487
"ls" ,
488
488
]
489
489
490
490
# Test empty command
491
- assert executor ._preprocess_command ([]) == []
491
+ assert executor .preprocessor . preprocess_command ([]) == []
492
492
493
493
494
494
def test_validate_pipeline (executor , monkeypatch ):
@@ -507,33 +507,35 @@ def test_validate_pipeline(executor, monkeypatch):
507
507
508
508
# Test disallowed commands in pipeline
509
509
with pytest .raises (ValueError ) as exc :
510
- executor ._validate_pipeline (["rm" , "|" , "grep" , "test" ])
510
+ executor .validator . validate_pipeline (["rm" , "|" , "grep" , "test" ])
511
511
assert "Command not allowed: rm" in str (exc .value )
512
512
513
513
# Test shell operators in pipeline
514
514
with pytest .raises (ValueError ) as exc :
515
- executor ._validate_pipeline (["echo" , "hello" , "|" , "grep" , "h" , "&&" , "ls" ])
515
+ executor .validator .validate_pipeline (
516
+ ["echo" , "hello" , "|" , "grep" , "h" , "&&" , "ls" ]
517
+ )
516
518
assert "Unexpected shell operator in pipeline: &&" in str (exc .value )
517
- assert executor ._preprocess_command ([]) == []
519
+ assert executor .preprocessor . preprocess_command ([]) == []
518
520
519
521
520
522
def test_redirection_path_validation (executor ):
521
523
"""Test validation of redirection paths"""
522
524
# Test missing output redirection path
523
525
with pytest .raises (ValueError , match = "Missing path for output redirection" ):
524
- executor ._parse_command (["echo" , "hello" , ">" ])
526
+ executor .preprocessor . parse_command (["echo" , "hello" , ">" ])
525
527
526
528
# Test missing input redirection path
527
529
with pytest .raises (ValueError , match = "Missing path for input redirection" ):
528
- executor ._parse_command (["cat" , "<" ])
530
+ executor .preprocessor . parse_command (["cat" , "<" ])
529
531
530
532
# Test operator as redirection target
531
533
with pytest .raises (ValueError , match = "Invalid redirection target: operator found" ):
532
- executor ._parse_command (["echo" , "hello" , ">" , ">" ])
534
+ executor .preprocessor . parse_command (["echo" , "hello" , ">" , ">" ])
533
535
534
536
# Test multiple operators
535
537
with pytest .raises (ValueError , match = "Invalid redirection target: operator found" ):
536
- executor ._parse_command (["echo" , "hello" , ">" , ">>" , "file.txt" ])
538
+ executor .preprocessor . parse_command (["echo" , "hello" , ">" , ">>" , "file.txt" ])
537
539
538
540
539
541
@pytest .mark .asyncio
@@ -565,13 +567,18 @@ async def test_io_handle_close(executor, temp_test_dir, monkeypatch, mocker):
565
567
def test_preprocess_command_pipeline (executor ):
566
568
"""Test pipeline command preprocessing functionality"""
567
569
# Test empty command
568
- assert executor ._preprocess_command ([]) == []
570
+ assert executor .preprocessor . preprocess_command ([]) == []
569
571
570
572
# Test single command without pipe
571
- assert executor ._preprocess_command (["echo" , "hello" ]) == ["echo" , "hello" ]
573
+ assert executor .preprocessor .preprocess_command (["echo" , "hello" ]) == [
574
+ "echo" ,
575
+ "hello" ,
576
+ ]
572
577
573
578
# Test simple pipe
574
- assert executor ._preprocess_command (["echo" , "hello" , "|" , "grep" , "h" ]) == [
579
+ assert executor .preprocessor .preprocess_command (
580
+ ["echo" , "hello" , "|" , "grep" , "h" ]
581
+ ) == [
575
582
"echo" ,
576
583
"hello" ,
577
584
"|" ,
@@ -580,12 +587,12 @@ def test_preprocess_command_pipeline(executor):
580
587
]
581
588
582
589
# Test multiple pipes
583
- assert executor ._preprocess_command (
590
+ assert executor .preprocessor . preprocess_command (
584
591
["cat" , "file" , "|" , "grep" , "pattern" , "|" , "wc" , "-l" ]
585
592
) == ["cat" , "file" , "|" , "grep" , "pattern" , "|" , "wc" , "-l" ]
586
593
587
594
# Test command with attached pipe operator
588
- assert executor ._preprocess_command (["echo|" , "grep" , "pattern" ]) == [
595
+ assert executor .preprocessor . preprocess_command (["echo|" , "grep" , "pattern" ]) == [
589
596
"echo" ,
590
597
"|" ,
591
598
"grep" ,
0 commit comments