def test_phone_too_long_triggers_validation_error(self): data = self._get_data() data[ 'phone'] = '+55 81 982459204' # Real data entered by brazilian user! form = CallForProposalForm(data) self.assertFalse(form.is_valid()) self.assertIn('phone', form.errors)
def test_form_save_models(self): form = CallForProposalForm(self._get_data()) self.assertTrue(form.is_valid()) speaker, proposal = form.save_to_models() self.assertEqual(speaker.name, "Daniel Pyrathon") self.assertEqual(proposal.speaker, speaker) self.assertEqual(speaker.user.username, "*****@*****.**")
def test_form_save_models(self): form = CallForProposalForm(self._get_data()) self.assertTrue(form.is_valid()) speaker, proposal = form.save_to_models() self.assertEqual(speaker.name, "Daniel Pyrathon") self.assertEqual(proposal.speaker, speaker) self.assertEqual(proposal.speaker_and_talk_history, 'wooo2') self.assertEqual(proposal.talk_links, 'http://google.com') self.assertEqual(speaker.user.username, "*****@*****.**")
def test_cannot_ommit_fields(self): all_fields = set(self._get_data().keys()) all_fields.remove('website') for field_name in all_fields: data = self._get_data() del data[field_name] form = CallForProposalForm(data) self.assertFalse(form.is_valid()) self.assertIn(field_name, form.errors)
def test_form_save_models(self): form = CallForProposalForm(self._get_data()) self.assertTrue(form.is_valid()) speaker, proposal = form.save_to_models() self.assertEqual(speaker.name, "Daniel Pyrathon") self.assertEqual(proposal.speaker, speaker) self.assertEqual(proposal.speaker_and_talk_history, 'wooo2') self.assertEqual(proposal.talk_links, 'http://google.com') self.assertEqual(speaker.user.username, "*****@*****.**") self.assertEqual( 'python fundamentals & popular libraries,engineering a community', proposal.themes)
def test_cfp_form_works(self): form = CallForProposalForm(self._get_data()) self.assertTrue(form.is_valid()) self.assertEqual(len(form.cleaned_data), 13)