Skip to content

Commit 7125fd6

Browse files
committed
squashme: style
1 parent 3b205dd commit 7125fd6

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

components/renku_data_services/crc/blueprints.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Compute resource control (CRC) app."""
22

33
import asyncio
4+
from contextlib import suppress
45
from dataclasses import dataclass
56

67
from sanic import HTTPResponse, Request, empty, json
@@ -353,14 +354,12 @@ async def _delete(
353354
member_id=member_id,
354355
member_type=MemberType(member_type),
355356
)
356-
try:
357+
with suppress(errors.MissingResourceError):
357358
await self.repo.revoke_resource_pool_members(
358359
api_user=user,
359360
resource_pool_id=resource_pool_id,
360361
members=[identifier],
361362
)
362-
except errors.MissingResourceError:
363-
pass # Already removed or was not part of the pool
364363
return HTTPResponse(status=204)
365364

366365
return "/resource_pools/<resource_pool_id>/members/<member_type>/<member_id>", ["DELETE"], _delete

components/renku_data_services/crc/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ async def _prohibit_resource_pool_users(
13031303
resource_pool_id: int,
13041304
user_ids: Collection[str],
13051305
session: AsyncSession | None = None,
1306-
) -> models.ResourcePoolMembershipChange | None:
1306+
) -> models.ResourcePoolMembershipChange:
13071307
specs = [(uid, ResourceType.user, Role.PROHIBITED) for uid in user_ids]
13081308
return self._build_pool_membership_changes(resource_pool_id, specs, Change.ADD)
13091309

test/bases/renku_data_services/data_api/test_resource_pools.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,6 @@ async def test_resource_pool_visibility_toggle(
17071707

17081708
@pytest.mark.asyncio
17091709
@pytest.mark.xdist_group("sessions")
1710-
17111710
@pytest.mark.parametrize("total_limit,user_limit", [(1000, 200), (200, 1000), (200, 0), (0, 200)])
17121711
async def test_resource_pools_quota_with_partial_usage(
17131712
sanic_client,
@@ -1860,6 +1859,7 @@ async def test_resource_pools_quota_with_no_usage(
18601859
# usage_hours_total should be 4 hours (200 credits total limit / 50 credits per hour)
18611860
assert resource_class["usage_hours_total"] == 4.0
18621861

1862+
18631863
async def test_resource_pool_members_add_group(
18641864
sanic_client: SanicASGITestClient,
18651865
admin_headers: dict[str, str],
@@ -1916,10 +1916,8 @@ async def test_resource_pool_members_add_group(
19161916
assert member_1_user.id in user_ids
19171917

19181918

1919-
19201919
@pytest.mark.asyncio
19211920
@pytest.mark.xdist_group("sessions")
1922-
19231921
async def test_resource_pools_quota_exceeded(
19241922
sanic_client: SanicASGITestClient,
19251923
admin_headers: dict[str, str],
@@ -2000,6 +1998,7 @@ async def test_resource_pools_quota_exceeded(
20001998
# usage_hours_total should be 2.0 hours (50 credits/hour * 2 hours = 100 credits limit)
20011999
assert resource_class["usage_hours_total"] == 2.0
20022000

2001+
20032002
async def test_resource_pool_members_add_project(
20042003
sanic_client: SanicASGITestClient,
20052004
admin_headers: dict[str, str],
@@ -2056,10 +2055,8 @@ async def test_resource_pool_members_add_project(
20562055
assert member_1_user.id in user_ids
20572056

20582057

2059-
20602058
@pytest.mark.asyncio
20612059
@pytest.mark.xdist_group("sessions")
2062-
20632060
async def test_resource_pools_quota_with_no_limits(
20642061
sanic_client: SanicASGITestClient,
20652062
admin_headers: dict[str, str],
@@ -2132,6 +2129,7 @@ async def test_resource_pools_quota_with_no_limits(
21322129
# usage_hours_total should not exist in the response since it's None
21332130
assert "usage_hours_total" not in resource_class
21342131

2132+
21352133
async def test_resource_pool_members_put_replaces(
21362134
sanic_client: SanicASGITestClient,
21372135
admin_headers: dict[str, str],
@@ -2174,10 +2172,8 @@ async def test_resource_pool_members_put_replaces(
21742172
assert members[0]["id"] == group2["id"]
21752173

21762174

2177-
21782175
@pytest.mark.asyncio
21792176
@pytest.mark.xdist_group("sessions")
2180-
21812177
async def test_resource_pools_quota_with_no_costs(
21822178
sanic_client: SanicASGITestClient,
21832179
admin_headers: dict[str, str],
@@ -2254,6 +2250,7 @@ async def test_resource_pools_quota_with_no_costs(
22542250
# usage_hours_total should not exist in the response since it's None
22552251
assert "usage_hours_total" not in resource_class
22562252

2253+
22572254
async def test_resource_pool_members_delete(
22582255
sanic_client: SanicASGITestClient,
22592256
admin_headers: dict[str, str],
@@ -2931,4 +2928,3 @@ async def test_resource_pool_members_delete_nonexistent_project(
29312928
headers=admin_headers,
29322929
)
29332930
assert res.status_code == 204
2934-

0 commit comments

Comments
 (0)