def setUp(self): self.alice = UserFactory.create(username="******") self.space = CompetitionFactory.create(name="Space") self.galapagos = CompetitionFactory.create(name="Galapagos") self.galapagos.is_open = True self.galapagos.save() self.questions = [QuestionFactory.create(question_type=t) for t in ('SA', 'MC', 'AB', 'SC')] self.galapagos.questions.add(*self.questions)
def test_altered_questions(self): """Users should have to re-enter forms if questions are changed while the form's being filled out""" kwds = {'comp_slug': self.galapagos.slug} register_url = reverse("register_for", kwargs=kwds) with self.loggedInAs("alice", "123"): response = self.client.get(register_url) # Fill in old form data = self.fill_in_forms(response) # Add a new question self.galapagos.questions.add(QuestionFactory.create()) # Submit old form... which should redirect response = self.client.post(register_url, data=data, follow=True) messages = list(response.context['messages']) self.assertEqual(1, len(messages)) self.assertIn("changed", messages[0].message) self.assertRedirects(response, register_url)