samedi 4 juillet 2015

Is testing for REST access necessary/good?

I have made a rest API using django-rest-framework.

I have multiple API endpoints. Some are used for creation of objects, some are used for listing objects, some are used for getting counts of objects, etc.

In my tests, I test each endpoint to ensure that, say, the create endpoint will only accept POST requests. I test the list endpoints to ensure that they only accept GET, and not POST/PUT/PATCH/DELETE. Each endpoint corresponds to a view, which has a setting that determines what requests they allow, but the tests ensure that those settings work. The tests mainly assert a certain status code is returned.

The tests get pretty repetitive. The tests for the comments API is about 600 lines. Is this kind of testing necessary, and/or is there a simplified alternative?

Aucun commentaire:

Enregistrer un commentaire