Skip to content
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

1.6.0 - Shared Workspaces #197

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
363d00d
Reapply "Merge branch 'development' into phillips/custom_parameters"
Jan 29, 2025
d2733e2
Merge pull request #195 from hubmapconsortium/main
jpuerto-psc Feb 5, 2025
13c1225
feat: Move the routine to create users on main storage to the token r…
Feb 6, 2025
73c9237
feat: Exclude user that is performing the search
Feb 11, 2025
6ecce64
feat: Add datetime_(last_job_launch/last_modified)
Feb 11, 2025
dc9ad38
chore: Remove unused attribute
Feb 12, 2025
cff33b1
chore: Remove validity check that shouldn't be possiuble to reach
Feb 12, 2025
931ec59
chore: Add check for unaccepted shared workspaces
Feb 12, 2025
154839f
chore: Simplify error check
Feb 12, 2025
a6f410d
chore: Simplify error check
Feb 12, 2025
d88e14e
chore: Syntax changes
Feb 12, 2025
b5892b3
fix: Add new fields to tests
Feb 12, 2025
20b8f37
feat: Exclude non-accepted shared workspaces
Feb 12, 2025
936c2f6
fix: missing _
Feb 12, 2025
57e9d0b
chore: Remove TODO
Feb 12, 2025
69a879a
chore: Changes to be closer to other views
Feb 20, 2025
8e89b7b
test: Add tests for SharedWorkspaceMapping model
Feb 20, 2025
6c0fbd1
test: Add tests for SharedWorkspacesView
Feb 20, 2025
dfce81e
test: Add tests for UserView
Feb 20, 2025
bbdf958
test: Slight changes for Workspace View
Feb 20, 2025
08bb1e5
test: More tests
Feb 20, 2025
2a06e83
chore: import change
Feb 20, 2025
b419c54
Merge branch 'development' into jpuerto/sharing
jpuerto-psc Feb 20, 2025
a1350a4
chore: Remove whitespace
Feb 20, 2025
8bb243e
Merge pull request #196 from hubmapconsortium/jpuerto/sharing
jpuerto-psc Feb 20, 2025
2b9d60f
Update VERSION
jpuerto-psc Feb 20, 2025
f2982b6
fix: exclude admin user
Feb 26, 2025
cb5e32f
Merge pull request #198 from hubmapconsortium/jpuerto/sharing
jpuerto-psc Feb 26, 2025
73e605f
fix: Include workspace_details in response
Mar 13, 2025
9591167
fix: Include workspace_details in response
Mar 13, 2025
3f18e73
Merge pull request #199 from hubmapconsortium/jpuerto/sharing
jpuerto-psc Mar 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: More tests
Juan Puerto committed Feb 20, 2025
commit 08bb1e574c37a9ca31a859b20548ba308ffa74d1
94 changes: 94 additions & 0 deletions src/tests/unittests/test_views.py
Original file line number Diff line number Diff line change
@@ -216,6 +216,16 @@ def test_workspace_query_param_name_get(self):
response = self.client.get(f"{self.workspaces_url}?name={self.workspace.name}")
self.assertValidResponse(response, status.HTTP_200_OK, success=True)

def test_workspace_query_param_name_get_none_found(self):
self.client.force_authenticate(user=self.user)
response = self.client.get(f"{self.workspaces_url}?name=FakeWorkspace")
self.assertValidResponse(
response,
status.HTTP_200_OK,
success=True,
message="Workspace matching given parameters could not be found.",
)

def test_workspaces_get(self):
self.client.force_authenticate(user=self.user)
response = self.client.get(self.workspaces_url)
@@ -558,6 +568,19 @@ def test_workspace_start_invalid_job_details_put(self):
message="Job details not JSON.",
)

def test_workspace_start_resource_options_not_json_put(self):
self.client.force_authenticate(user=self.user)
body = {"job_type": "test_job", "job_details": {}, "resource_options": ""}
response = self.client.put(
reverse("workspaces_put_type", args=[self.workspace.id, "start"]), body
)
self.assertValidResponse(
response,
status.HTTP_400_BAD_REQUEST,
success=False,
message="Resource options not JSON.",
)

def test_workspace_start_invalid_file_path_put(self):
self.client.force_authenticate(user=self.user)
self.workspace.file_path = "."
@@ -574,6 +597,27 @@ def test_workspace_start_invalid_file_path_put(self):
"the workspace directory that will not allow for jobs to be created.",
)

def test_workspace_start_invalid_job_type_configuration(self):
apps.get_app_config("user_workspaces_server").available_job_types["test_job"][
"job_type"
] = "FakeJobType"
self.client.force_authenticate(user=self.user)
body = {"job_type": "test_job", "job_details": {}}
response = self.client.put(
reverse("workspaces_put_type", args=[self.workspace.id, "start"]), body
)

apps.get_app_config("user_workspaces_server").available_job_types["test_job"][
"job_type"
] = "LocalTestJob"

self.assertValidResponse(
response,
status.HTTP_400_BAD_REQUEST,
success=False,
message="Job Type improperly configured. Please contact a system administrator to resolve this.",
)

def test_workspace_start_minimum_valid_put(self):
self.client.force_authenticate(user=self.user)
body = {"job_type": "test_job", "job_details": {}}
@@ -1078,3 +1122,53 @@ def test_shared_workspace_delete_shared_user(self):
success=True,
message=f"Shared workspace {self.shared_workspace.pk} queued for deletion.",
)


class WorkspaceAndSharedWorkspaceAPITests(SharedWorkspaceAPITestCase):
def test_workspace_put_not_accepted_shared_workspace(self):
self.client.force_authenticate(user=self.user_2)
response = self.client.put(reverse("workspaces_with_id", args=[self.shared_workspace.pk]))
self.assertValidResponse(
response,
status.HTTP_400_BAD_REQUEST,
success=False,
message=f"Workspace {self.shared_workspace.pk} is a shared workspace and has not been accepted.",
)

def test_workspace_delete_not_accepted_shared_workspace(self):
self.client.force_authenticate(user=self.user_2)
response = self.client.delete(
reverse("workspaces_with_id", args=[self.shared_workspace.pk])
)
self.assertValidResponse(
response,
status.HTTP_400_BAD_REQUEST,
success=False,
message=f"Workspace {self.shared_workspace.pk} is a shared workspace and has not been accepted.",
)

def test_workspace_delete_original_workspace_with_not_accepted_shared_workspace(self):
self.client.force_authenticate(user=self.user)
response = self.client.delete(
reverse("workspaces_with_id", args=[self.original_workspace.pk])
)
self.assertValidResponse(
response,
status.HTTP_400_BAD_REQUEST,
success=False,
message=f"Workspace {self.original_workspace.pk} has shared workspaces associated with it, that have not yet been accepted. Please cancel those shares to delete this workspace.",
)

def test_workspace_delete_original_workspace_with_accepted_shared_workspace(self):
self.client.force_authenticate(user=self.user)
self.shared_workspace_mapping.is_accepted = True
self.shared_workspace_mapping.save()
response = self.client.delete(
reverse("workspaces_with_id", args=[self.original_workspace.pk])
)
self.assertValidResponse(
response,
status.HTTP_200_OK,
success=True,
message=f"Workspace {self.original_workspace.pk} queued for deletion.",
)