Skip to content

Commit

Permalink
💯 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyzhang01 committed Nov 13, 2024
1 parent a7a7eab commit 1b10057
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 137 deletions.
157 changes: 73 additions & 84 deletions backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions backend/gsr_booking/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def cancel_room(self, booking_id: str, user: UserType) -> dict[str, Any]:

@abstractmethod
def get_availability(
self, lid: int, start: str | None, end: str | None, user: UserType
self, lid: str | int, start: str | None, end: str | None, user: UserType
) -> list[RoomInfo]:
raise NotImplementedError # pragma: no cover

Expand Down Expand Up @@ -111,7 +111,7 @@ def cancel_room(self, booking_id: str, user: UserType) -> dict[str, Any]:
return response

def get_availability(
self, lid: int, start: str | None, end: str | None, user: UserType
self, lid: str | int, start: str | None, end: str | None, user: UserType
) -> list[RoomInfo]:
"""Returns a list of rooms and their availabilities"""
current_time = timezone.localtime()
Expand Down Expand Up @@ -275,7 +275,7 @@ def cancel_room(self, booking_id: str, user: UserType) -> dict[str, Any]:
return response

def get_availability(
self, gid: int, start: str | None, end: str | None, user: UserType
self, gid: str | int, start: str | None, end: str | None, user: UserType
) -> list[RoomInfo]:
"""Returns a list of rooms and their availabilities"""

Expand Down Expand Up @@ -536,9 +536,6 @@ def get_availability(
) -> AvailabilityResponse:
gsr = get_object_or_404(GSR, gid=gid)

lid_int = int(lid) if isinstance(lid, str) else lid
gid_int = int(gid) if isinstance(gid, str) else gid

# select a random user from the group if booking wharton gsr
if gsr.kind == GSR.KIND_WHARTON and group is not None:
wharton_members = group.memberships.filter(is_wharton=True)
Expand All @@ -547,9 +544,9 @@ def get_availability(
user = wharton_members[randint(0, n - 1)].user

rooms = (
self.WBW.get_availability(lid_int, start, end, user)
self.WBW.get_availability(lid, start, end, user)
if gsr.kind == GSR.KIND_WHARTON
else self.LBW.get_availability(gid_int, start, end, user)
else self.LBW.get_availability(gid, start, end, user)
)
return {"name": gsr.name, "gid": gsr.gid, "rooms": rooms}

Expand Down
Loading

0 comments on commit 1b10057

Please sign in to comment.