<div dir="ltr"><div>I'm setting up a whole testing infrastructure for our project, that uses bottle for the backend and django for the fronted.</div><div><br></div><div>We have a suite of unit tests for the backend and for django.</div>
<div><br></div><div>The nice thing about this is that I set up a git pre-commit hook so that everyone runs always all the te</div><div>sts (almost 200) and it takes less than 2 seconds.</div><div><br></div><div>For django for eaxmple I test forms in a similar way:</div>
<div><br></div><div> def test_new_invalid_form_shows_challenges_dropdown(self):</div><div> without_ch = ideas_forms.NewIdeaForm(request=FakeRequest(), data={'title': 'title'})</div><div> rendered = without_ch.fields['challenge'].widget.render('x', 'y')</div>
<div> self.assertTrue(is_multiple_choice(rendered))</div><div><br></div><div>so I check the rendering of the widget, the validation and so on.</div><div>Then I also test all the "pure" functions that are not doing rendering and redirects.</div>
<div><br></div><div>Now I would also like to unit test the render and redirects, but I am a bit in trouble because for example redirects try to do a reverse routing, which then fails in the unit tests.</div><div><br></div>
<div>One way would be to mock redirect and just check that it gets called with the right arguments which would already be good enough, but maybe there are other ways?</div><div><br></div><div>I don't really want to use the django client, because it's too slow and they would not be unit tests anymore. In plus for integration tests I would rather spend time with selenium, that at least really checks the whole flow.</div>
<div><br></div><div>What do you think?</div></div>