jeudi 29 octobre 2020

How to test an api, making use of a django view function

I currently have a Django API mixed with some GRPC stuff. The API makes use of a Django view function


@require_GET
def django_view_fn():
  pass

within the api

class API:
  
  def api_funct(self):
     result = def django_view_fn
     return result.pb
     

everything works well as it is right now during normal operation, eg via postman. The only problem I have is, the function doesn't work during Django test/TestCase. It returns a 405 as the response, instead of the expected response from the view function.

it only works if I comment out the @require_GET on the view function decorator in the view file

Aucun commentaire:

Enregistrer un commentaire