I want to be able to test various constraints that I have on my Django API.
I'm having difficulty doing this with the django.test.Client.
// prepare my_thing so it cannot be deleted
my_thing.save()
response = Client().delete('/my_things/%s/' % my_thing.id,
content_type='application/x-www-form-urlencoded')
self.assertEquals(204, response.status_code)
Even if the constraints prevent deletion, tests like this will pass successfully.
Is there a way to unit test Django constraints? I could write a test that uses requests but that would require the API to be running, which I don't want to require.
Aucun commentaire:
Enregistrer un commentaire