I need to test the methods and helper function inside a django Class Based View.
Consider this Class Based View:
class MyClassBasedView(View):
def dispatch(self, request, *args, **kwargs):
....
def __get_render_dict():
d = {}
...
return d
def my_method(self):
render_dict = self.__get_render_dict()
return render_response(self.request, 'template.html', render_dict)
In order to write unit tests for my view, I need to call the methods inside, say __get_render_dict()
directly. How can I achieve this?.
I've tried
v = MyClassedBasedView()
v.dispatch(request,args, kwargs)
v.__method_name()
but this fails with not matching parameters in post/get method, even though I was calling the method direclty without using URL.