|
|
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock, call, patch
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
-from opendevin.core.config import SandboxConfig, config
|
|
|
+from opendevin.core.config import SandboxConfig
|
|
|
from opendevin.events.action import IPythonRunCellAction
|
|
|
from opendevin.events.observation import IPythonRunCellObservation
|
|
|
from opendevin.runtime.docker.ssh_box import DockerSSHBox
|
|
|
@@ -78,34 +78,25 @@ async def test_run_python_backticks():
|
|
|
|
|
|
|
|
|
def test_sandbox_jupyter_plugin_backticks(temp_dir):
|
|
|
- # get a temporary directory
|
|
|
- with patch.object(config, 'workspace_base', new=temp_dir), patch.object(
|
|
|
- config, 'workspace_mount_path', new=temp_dir
|
|
|
- ), patch.object(config, 'run_as_devin', new='true'), patch.object(
|
|
|
- config.sandbox, 'box_type', new='ssh'
|
|
|
- ):
|
|
|
- box = DockerSSHBox(
|
|
|
- config=config.sandbox,
|
|
|
- persist_sandbox=config.persist_sandbox,
|
|
|
- workspace_mount_path=config.workspace_mount_path,
|
|
|
- sandbox_workspace_dir=config.workspace_mount_path_in_sandbox,
|
|
|
- cache_dir=config.cache_dir,
|
|
|
- run_as_devin=config.run_as_devin,
|
|
|
- ssh_hostname=config.ssh_hostname,
|
|
|
- ssh_password=config.ssh_password,
|
|
|
- ssh_port=config.ssh_port,
|
|
|
- )
|
|
|
- box.init_plugins([JupyterRequirement])
|
|
|
- test_code = "print('Hello, `World`!')"
|
|
|
- expected_write_command = (
|
|
|
- "cat > /tmp/opendevin_jupyter_temp.py <<'EOL'\n" f'{test_code}\n' 'EOL'
|
|
|
- )
|
|
|
- expected_execute_command = 'cat /tmp/opendevin_jupyter_temp.py | execute_cli'
|
|
|
- exit_code, output = box.execute(expected_write_command)
|
|
|
- exit_code, output = box.execute(expected_execute_command)
|
|
|
- print(output)
|
|
|
- assert exit_code == 0, 'The exit code should be 0 for ' + box.__class__.__name__
|
|
|
- assert output.strip() == 'Hello, `World`!', (
|
|
|
- 'The output should be the same as the input for ' + box.__class__.__name__
|
|
|
- )
|
|
|
- box.close()
|
|
|
+ box = DockerSSHBox(
|
|
|
+ config=SandboxConfig(),
|
|
|
+ persist_sandbox=False,
|
|
|
+ workspace_mount_path=temp_dir,
|
|
|
+ sandbox_workspace_dir='/workspace',
|
|
|
+ cache_dir='/tmp/cache',
|
|
|
+ run_as_devin=True,
|
|
|
+ )
|
|
|
+ box.init_plugins([JupyterRequirement])
|
|
|
+ test_code = "print('Hello, `World`!')"
|
|
|
+ expected_write_command = (
|
|
|
+ "cat > /tmp/opendevin_jupyter_temp.py <<'EOL'\n" f'{test_code}\n' 'EOL'
|
|
|
+ )
|
|
|
+ expected_execute_command = 'cat /tmp/opendevin_jupyter_temp.py | execute_cli'
|
|
|
+ exit_code, output = box.execute(expected_write_command)
|
|
|
+ exit_code, output = box.execute(expected_execute_command)
|
|
|
+ print(output)
|
|
|
+ assert exit_code == 0, 'The exit code should be 0 for ' + box.__class__.__name__
|
|
|
+ assert output.strip() == 'Hello, `World`!', (
|
|
|
+ 'The output should be the same as the input for ' + box.__class__.__name__
|
|
|
+ )
|
|
|
+ box.close()
|