def test_series_is_created_for_new_event(self): form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), True) form.save() series = Series.objects.all() self.assertEquals(len(series), 1) self.assertEquals(series[0].name, "Correct Event")
def test_foreign_key_for_event_is_set(self): form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), True) form.save() series = Series.objects.all()[0] event = Event.objects.all()[0] self.assertEquals(event.series, series)
def test_event_is_created(self): form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), True) form.save() events = Event.objects.all() event = events[0] self.assertEquals(len(events), 1) self.assertEquals(event.name, "Correct Event")
def create_event(request, room_id): room = get_object_or_404(Room, pk=room_id) if request.method == "POST": form = CreateEventForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('booking:detail', args=[room.id])) else: form = CreateEventForm() return render(request, 'booking/create_event.html', { 'form': form, 'room': room })
def test_series_data_matches_event_data(self): form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), True) form.save() series = Series.objects.all()[0] event = Event.objects.all()[0] self.assertEquals(series.setupStartTime, event.setupStartTime) self.assertEquals(series.eventStartTime, event.eventStartTime) self.assertEquals(series.eventEndTime, event.eventEndTime) self.assertEquals(series.teardownEndTime, event.teardownEndTime) self.assertEquals(series.name, event.name) self.assertEquals(series.notes, event.notes) self.assertEquals(series.rooms.all()[0], event.rooms.all()[0]) self.assertEquals(series.attributes.all()[0], event.attributes.all()[0]) self.assertEquals(series.attributes.all()[1], event.attributes.all()[1])