mirror of https://github.com/snachodog/mybuddy.git
Reworked POST to PATCH endpoints
Signed-off-by: Paul Konstantin Gerke <paulkgerke@craftware.info>
This commit is contained in:
parent
cf58ae6aba
commit
63d0b1373a
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue