Esempio n. 1
0
 def test_form_save(self):
     form = EventForm(self.form_values)
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(Event.objects.all().count(), 1)
     event = Event.objects.get(name=self.form_values['name'])
     self.assertEqual(event.tags.all().count(), 2)
Esempio n. 2
0
 def test_edit_form(self):
     form_data = self.event_form_data
     form_data['name'] = 'Test Edit Form'
     event = EventForm(form_data)
     event.is_valid()
     event.save()
     event = Event.objects.get(name='Test Edit Form')
     form_data['name'] = 'Test Edit Form 2'
     request = self.factory.post('/event/edit/%s' % event.id, form_data)
     results = edit_form(request, Event, EventForm, event.id)
     self.assertTrue('success_message' in results)