<div dir="ltr"><div>I&#39;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={&#39;title&#39;: &#39;title&#39;})</div><div>        rendered = without_ch.fields[&#39;challenge&#39;].widget.render(&#39;x&#39;, &#39;y&#39;)</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 &quot;pure&quot; 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&#39;t really want to use the django client, because it&#39;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>