def test_write_environment_script_file(self): base_dir = '/path' local_script_path = '/local/script/path.py' paths = ssh_operations._Paths(base_dir=base_dir, local_script_path=local_script_path) env = {'one': "'1'"} local_socket_url = 'local_socket_url' remote_socket_url = 'remote_socket_url' env_script_lines = set([ l for l in ssh_operations._write_environment_script_file( process={ 'env': env }, paths=paths, local_socket_url=local_socket_url, remote_socket_url=remote_socket_url).getvalue().split('\n') if l ]) expected_env_script_lines = set([ 'export PATH=/path:$PATH', 'export PYTHONPATH=/path:$PYTHONPATH', 'chmod +x /path/ctx', 'chmod +x {0}'.format(paths.remote_script_path), 'export CTX_SOCKET_URL={0}'.format(remote_socket_url), 'export LOCAL_CTX_SOCKET_URL={0}'.format(local_socket_url), 'export one=\'1\'' ]) assert env_script_lines == expected_env_script_lines
def test_paths(self): base_dir = '/path' local_script_path = '/local/script/path.py' paths = ssh_operations._Paths(base_dir=base_dir, local_script_path=local_script_path) assert paths.local_script_path == local_script_path assert paths.remote_ctx_dir == base_dir assert paths.base_script_path == 'path.py' assert paths.remote_ctx_path == '/path/ctx' assert paths.remote_scripts_dir == '/path/scripts' assert paths.remote_work_dir == '/path/work' assert paths.remote_env_script_path.startswith('/path/scripts/env-path.py-') assert paths.remote_script_path.startswith('/path/scripts/path.py-')