Skip to content

Commit

Permalink
Order rooms by their name by default
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Jan 22, 2025
1 parent 799b59e commit 5e31798
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/services/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def all(self) -> list[RoomDetails]:
list[RoomDetails]: List of all `RoomDetails`
"""
# Select all entries in `Room` table
query = select(RoomEntity).order_by(RoomEntity.capacity)
query = select(RoomEntity).order_by(RoomEntity.nickname)
entities = self._session.scalars(query).all()

# Convert entries to a model and return
Expand Down
5 changes: 3 additions & 2 deletions backend/test/services/room_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for Coworking Rooms Service."""

from unittest.mock import create_autospec
import pytest
from backend.services.exceptions import (
Expand Down Expand Up @@ -32,10 +33,10 @@ def test_list(room_svc: RoomService):
assert isinstance(rooms[0], RoomDetails)


def test_list_ordered_by_capacity(room_svc: RoomService):
def test_list_ordered_by_name(room_svc: RoomService):
rooms = room_svc.all()
for i in range(1, len(rooms)):
assert rooms[i - 1].capacity <= rooms[i].capacity
assert rooms[i - 1].nickname <= rooms[i].nickname


def test_get_by_id(room_svc: RoomService):
Expand Down

0 comments on commit 5e31798

Please sign in to comment.