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

[24.1] Allow to change only the description of a quota #18775

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions lib/galaxy/managers/quotas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
Union,
)

from sqlalchemy import select
from sqlalchemy import (
and_,
select,
)

from galaxy import (
model,
Expand Down Expand Up @@ -115,10 +118,10 @@ def _parse_amount(self, amount: str) -> Optional[Union[int, bool]]:
return False

def rename_quota(self, quota, params) -> str:
stmt = select(Quota).where(Quota.name == params.name).limit(1)
stmt = select(Quota).where(and_(Quota.name == params.name, Quota.id != quota.id)).limit(1)
nsoranzo marked this conversation as resolved.
Show resolved Hide resolved
if not params.name:
raise ActionInputError("Enter a valid name.")
elif params.name != quota.name and self.sa_session.scalars(stmt).first():
elif self.sa_session.scalars(stmt).first():
raise ActionInputError("A quota with that name already exists.")
else:
old_name = quota.name
Expand Down
20 changes: 20 additions & 0 deletions test/integration/test_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ def test_update(self):
json_response = show_response.json()
assert json_response["name"] == new_quota_name

def test_update_description(self):
quota_name = "test-update-quota-description"
quota = self._create_quota_with_name(quota_name)
quota_id = quota["id"]

# update description (one needs to specify a name even if should not be changed)
quota_description = "description of test-updated-quota-name"
update_payload = {
"name": quota_name,
"description": quota_description,
}
put_response = self._put(f"quotas/{quota_id}", data=update_payload, json=True)
put_response.raise_for_status()

show_response = self._get(f"quotas/{quota_id}")
show_response.raise_for_status()
json_response = show_response.json()
assert json_response["name"] == quota_name
assert json_response["description"] == quota_description

def test_delete(self):
quota_name = "test-delete-quota"
quota = self._create_quota_with_name(quota_name)
Expand Down
Loading