Reworked POST to PATCH endpoints

Signed-off-by: Paul Konstantin Gerke <paulkgerke@craftware.info>
This commit is contained in:
Paul Konstantin Gerke 2022-01-10 16:03:18 +01:00 committed by Christopher Charbonneau Wells
parent cf58ae6aba
commit 63d0b1373a
2 changed files with 6 additions and 6 deletions

View File

@ -404,7 +404,7 @@ class TimerAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertFalse(response.data["active"])
response = self.client.post(f"{endpoint}restart/")
response = self.client.patch(f"{endpoint}restart/")
self.assertEqual(response.status_code, status.HTTP_200_OK)
response = self.client.get(endpoint)
@ -412,10 +412,10 @@ class TimerAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
self.assertTrue(response.data["active"])
# Restart twice fails
response = self.client.post(f"{endpoint}restart/")
response = self.client.patch(f"{endpoint}restart/")
self.assertEqual(response.status_code, status.HTTP_412_PRECONDITION_FAILED)
response = self.client.post(f"{endpoint}stop/")
response = self.client.patch(f"{endpoint}stop/")
self.assertEqual(response.status_code, status.HTTP_200_OK)
response = self.client.get(endpoint)
@ -423,7 +423,7 @@ class TimerAPITestCase(TestBase.BabyBuddyAPITestCaseBase):
self.assertFalse(response.data["active"])
# Stopping twice fails
response = self.client.post(f"{endpoint}stop/")
response = self.client.patch(f"{endpoint}stop/")
self.assertEqual(response.status_code, status.HTTP_412_PRECONDITION_FAILED)

View File

@ -61,7 +61,7 @@ class TimerViewSet(viewsets.ModelViewSet):
status=status.HTTP_404_NOT_FOUND
)
@action(detail=True, methods=['post'])
@action(detail=True, methods=['patch'])
def stop(self, request, pk=None):
def do_stop(timer):
if not timer.active:
@ -73,7 +73,7 @@ class TimerViewSet(viewsets.ModelViewSet):
return Response({"detail": "timer stopped"})
return self.__timer_operation(pk, do_stop)
@action(detail=True, methods=['post'])
@action(detail=True, methods=['patch'])
def restart(self, request, pk=None):
def do_restart(timer):
if timer.active: