def test_q_register_redirect(self): """ just like test_q_register_post, but tries to fill out the "honeypot" field :return: """ redirect_to = "/test/" query_limit = FuzzyInt(0, 10) with self.assertNumQueries(query_limit): request_url = add_parameters_to_url( reverse("register"), next=redirect_to # adding the redirection parameter here ) response = self.client.get(request_url) registration_form = response.context["form"] post_data = get_data_from_form(registration_form, include={ settings.HONEYPOT_FIELD_NAME: u"", # the honeypot field }) post_data["username"] = "******" post_data["password1"] = "PaSsWoRd123!" post_data["password2"] = "PaSsWoRd123!" response = self.client.post(request_url, data=post_data, follow=True) self.assertEqual(response.status_code, 200) self.assertEqual(response.request["PATH_INFO"], redirect_to)
def test_q_register_post(self): query_limit = FuzzyInt(0, 10) with self.assertNumQueries(query_limit): request_url = reverse("register", kwargs={}) response = self.client.get(request_url) registration_form = response.context["form"] post_data = get_data_from_form(registration_form, include={ settings.HONEYPOT_FIELD_NAME: u"", # the honeypot field }) post_data["username"] = "******" post_data["password1"] = "PaSsWoRd123!" post_data["password2"] = "PaSsWoRd123!" response = self.client.post(request_url, data=post_data, follow=True) self.assertEqual(response.status_code, 200)