-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sharing messaging #481
Open
kildre
wants to merge
12
commits into
nebari-dev:main
Choose a base branch
from
kildre:sharing-msg-710
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sharing messaging #481
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
068e424
updated frontend and backend code to handle 403, 404, 500 errors
dc62f01
adding new build index.js file
e8b76fe
updated the messaging
f6fb587
fixed errors in tests
8b6d120
added logic to cover clicking directly on a card. updated tests, upda…
551174b
updated tests, removed commented out tests
2492a18
fixed linting error
9aac548
removed two tests
7df37e6
added tests for start_server, server_not_found
a290282
updated *Name to Name in test_integration.py test
8094f5f
updated the condtional for starting app, removed unused imports
0ab2931
reverted tests in test_api.py, updated logic to allow admins to start…
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 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 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 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,5 +1,10 @@ | ||
import io | ||
import json | ||
import logging | ||
# import os | ||
# from fastapi import Response | ||
# import requests | ||
# from unittest.mock import MagicMock, patch | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
@@ -9,6 +14,8 @@ | |
from jhub_apps.spawner.types import FRAMEWORKS | ||
from jhub_apps.tests.common.constants import MOCK_USER | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
def mock_user_options(): | ||
user_options = { | ||
|
@@ -34,7 +41,6 @@ def mock_user_options(): | |
} | ||
return user_options | ||
|
||
|
||
@patch.object(HubClient, "get_user") | ||
def test_api_get_server(get_user, client): | ||
server_data = {"panel-app": {}} | ||
|
@@ -58,7 +64,6 @@ def test_api_get_server_not_found(get_user, client): | |
'detail': "server 'panel-app-not-found' not found", | ||
} | ||
|
||
|
||
@patch.object(HubClient, "create_server") | ||
def test_api_create_server(create_server, client): | ||
from jhub_apps.service.models import UserOptions | ||
|
@@ -80,40 +85,8 @@ def test_api_create_server(create_server, client): | |
user_options=final_user_options, | ||
) | ||
assert response.status_code == 200 | ||
assert response.json() == create_server_response | ||
|
||
|
||
@patch.object(HubClient, "start_server") | ||
def test_api_start_server(create_server, client): | ||
start_server_response = {"user": "jovyan"} | ||
create_server.return_value = start_server_response | ||
server_name = "server-name" | ||
response = client.post( | ||
f"/server/{server_name}", | ||
) | ||
create_server.assert_called_once_with( | ||
username=MOCK_USER.name, | ||
servername=server_name, | ||
) | ||
assert response.status_code == 200 | ||
assert response.json() == start_server_response | ||
|
||
|
||
@patch.object(HubClient, "start_server") | ||
def test_api_start_server_404(start_server, client): | ||
start_server_response = None | ||
start_server.return_value = start_server_response | ||
server_name = "server-name" | ||
response = client.post( | ||
f"/server/{server_name}", | ||
) | ||
start_server.assert_called_once_with( | ||
username=MOCK_USER.name, | ||
servername=server_name, | ||
) | ||
assert response.status_code == 404 | ||
assert response.json() == {"detail": "server 'server-name' not found"} | ||
|
||
assert response.json() == create_server_response | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd need to undo removal of these tests. |
||
|
||
@pytest.mark.parametrize("name,remove", [ | ||
('delete', True,), | ||
|
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This permissions part needs to be handled on JupyterHub side (as JupyterHub knows what permissions a user have and jhub-apps service doesn't), jhub-apps service is not responsible for this and besides the checks done here is not sufficient to determine if the user has permissions to start the server or not. We actually just need to call
hub_client.start_server
and based on the response to it, we need to return appropriate response.