Skip to content

Commit

Permalink
adress codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
Porcupine1 committed Jan 2, 2025
1 parent c97c7eb commit ff8709a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 1 addition & 6 deletions backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5245,12 +5245,7 @@ def partial_update(self, request, *args, **kwargs):
description = request.data.get("description")

# attendance update
if attended is not None:
if not isinstance(attended, bool):
return Response(
{"detail": "Missing boolean attribute 'attended'."},
status=status.HTTP_400_BAD_REQUEST,
)
if isinstance(attended, bool):
ticket.attended = attended
ticket.save()
return Response(TicketSerializer(ticket).data)
Expand Down
20 changes: 20 additions & 0 deletions backend/tests/clubs/test_ticketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,26 @@ def test_update_attendance_non_officer(self):
self.assertEqual(resp.status_code, 404, resp.content)
self.assertFalse(ticket.attended)

def test_update_no_valid_parameters(self):
self.client.login(username=self.user1.username, password="test")
Membership.objects.create(
person=self.user1,
club=self.club1,
title="Officer",
role=Membership.ROLE_OFFICER,
)
ticket = self.tickets1[0]
ticket.save()

resp = self.client.patch(
reverse("tickets-detail", args=(ticket.id,)),
format="json",
)
ticket.refresh_from_db()
self.assertEqual(resp.status_code, 400, resp.content)
data = json.loads(resp.content.decode("utf-8"))
self.assertEquals(data["detail"], "No valid update parameters provided.")

def test_create_ticket_with_description(self):
self.client.login(username=self.user1.username, password="test")
qts = {
Expand Down

0 comments on commit ff8709a

Please sign in to comment.