Skip to content

Commit

Permalink
feat: add alias to assertResponseCreated and assertResponseUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodaher committed May 1, 2024
1 parent 4779568 commit d346d61
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drf_kit/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import inspect
import logging
import os
import re
from collections.abc import Callable, Iterable
Expand All @@ -16,6 +17,8 @@
from rest_framework.response import Response
from rest_framework.test import APITransactionTestCase

logger = logging.getLogger("drf-kit")


class BaseApiTest(APITransactionTestCase):
maxDiff = None
Expand Down Expand Up @@ -94,22 +97,30 @@ def assertResponseCreate(self, expected_item: dict, response: Response):
response_key=None,
)

def assertResponseUpdated(self, expected_item: dict, response: Response):
def assertResponseUpdate(self, expected_item: dict, response: Response):
self.assertResponse(
expected_status=status.HTTP_200_OK,
expected_body=expected_item,
response=response,
response_key=None,
)

def assertResponseDeleted(self, response: Response):
def assertResponseUpdated(self, expected_item: dict, response: Response):
logger.info("Please use assertResponseUpdate instead")
self.assertResponseUpdate(expected_item=expected_item, response=response)

def assertResponseDelete(self, response: Response):
self.assertResponse(
expected_status=status.HTTP_204_NO_CONTENT,
expected_body="",
response=response,
response_key=None,
)

def assertResponseDeleted(self, response: Response):
logger.info("Please use assertResponseDelete instead")
self.assertResponseDelete(response=response)

def assertResponseNotAllowed(self, response: Response):
method = response.request["REQUEST_METHOD"]
expected = {"detail": f'Method "{method}" not allowed.'}
Expand Down

0 comments on commit d346d61

Please sign in to comment.