-
Notifications
You must be signed in to change notification settings - Fork 347
adding cwd param to terminal api endpoint #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ef51f40
adding cwd param to terminal api endpoint
d0bd5f9
Adding terminal tests and new terminal kwargs
14c3403
fixing fetch method in terminal tests
47edae8
attempting to fix windows tests for terminal
c13abf0
fixing condition for windows in terminal tests
605eaa8
Updating terminal tests to skip windows
b673945
Merge branch 'master' into feature/cwd-for-terminal
Zsailer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pytest_plugins = ['pytest_jupyter_server'] | ||
pytest_plugins = ['pytest_jupyter_server'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import shutil | ||
import pytest | ||
import json | ||
import asyncio | ||
import sys | ||
|
||
|
||
@pytest.fixture | ||
def terminal_path(tmp_path): | ||
subdir = tmp_path.joinpath('terminal_path') | ||
subdir.mkdir() | ||
|
||
yield subdir | ||
|
||
shutil.rmtree(str(subdir), ignore_errors=True) | ||
|
||
|
||
async def test_terminal_create(fetch): | ||
await fetch( | ||
'api', 'terminals', | ||
method='POST', | ||
allow_nonstandard_methods=True, | ||
) | ||
|
||
resp_list = await fetch( | ||
'api', 'terminals', | ||
method='GET', | ||
allow_nonstandard_methods=True, | ||
) | ||
|
||
data = json.loads(resp_list.body.decode()) | ||
|
||
assert len(data) == 1 | ||
|
||
|
||
async def test_terminal_create_with_kwargs(fetch, ws_fetch, terminal_path): | ||
resp_create = await fetch( | ||
'api', 'terminals', | ||
method='POST', | ||
body=json.dumps({'cwd': str(terminal_path)}), | ||
allow_nonstandard_methods=True, | ||
) | ||
|
||
data = json.loads(resp_create.body.decode()) | ||
term_name = data['name'] | ||
|
||
resp_get = await fetch( | ||
'api', 'terminals', term_name, | ||
method='GET', | ||
allow_nonstandard_methods=True, | ||
) | ||
|
||
data = json.loads(resp_get.body.decode()) | ||
|
||
assert data['name'] == term_name | ||
|
||
|
||
@pytest.mark.skipif(sys.platform == 'win32', reason="Test times out on Windows.") | ||
async def test_terminal_create_with_cwd(fetch, ws_fetch, terminal_path): | ||
resp = await fetch( | ||
'api', 'terminals', | ||
method='POST', | ||
body=json.dumps({'cwd': str(terminal_path)}), | ||
allow_nonstandard_methods=True, | ||
) | ||
|
||
data = json.loads(resp.body.decode()) | ||
term_name = data['name'] | ||
|
||
ws = await ws_fetch( | ||
'terminals', 'websocket', term_name | ||
) | ||
|
||
ws.write_message(json.dumps(['stdin', 'pwd\r\n'])) | ||
|
||
message_stdout = '' | ||
while True: | ||
try: | ||
message = await asyncio.wait_for(ws.read_message(), timeout=1.0) | ||
except asyncio.TimeoutError: | ||
break | ||
|
||
message = json.loads(message) | ||
|
||
if message[0] == 'stdout': | ||
message_stdout += message[1] | ||
|
||
ws.close() | ||
|
||
assert str(terminal_path) in message_stdout |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.