python - How to unit test Django rest framework requests? -


i have django-rest-framework api, want unit test. more specifically, want unit test data validation methods separately. these data validation methods request parameter, so:

def validate(request) 

in order test separately, need way create requests. in django-rest-framework, there apirequestfactory, can used in creating requests. main problem is, apirequestfactory not create same request django-rest-framework uses. instead, create regular django requests stated site:

note: when using apirequestfactory, object returned django's standard httprequest, , not rest framework's request object, generated once view called.

but because validation methods use django-rest-frameworks request, cannot unit test using apirequestfactory. there way unit test separately those, or should use apiclient, , try test whole apiview? wouldn't want that, because not pure unit test. , apiclient, can responses, not requests. why there not apirequestfactory django-rest-framework requests? mean, if ones used in django-rest, why request factory doesn't generate instead?

was able bypass not sending request validation method, instead request.data. way validation methods got independent on request, rely on data sent them.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -