I have a Django view that ends with this...
return render(request, 'define/see_all.html', context)
I have mocked the render function and
@patch('define.views_func.render')
def test_get_define_see_all_complete(self, mock_render):
"""Testing that the queryset returned properly"""
things = AllThings(group="Word Editors")
things.model['definition'].is_complete = True
things.model['definition'].save()
t_url = reverse(
'define:get',
kwargs={'language': things.model['language']}) \
+ "?action=seeall&complete=True"
req = self.rf.post(t_url, {"nada": "nada"})
see_all(req, {'language': things.model['language']})
self.assertTrue(len(mock_render.call_args[0][2]['words'].object_list) == 1)
I am basically just trying to see that the context that was passed to render contains the appropriate output from the view, but yuck the last line looks like garbage to me and I know I will not understand it if I come back to look at it later. Is there a better way to do this?