def test_teardown_after_end_time(self): self.postData['eventEndTime_1'] = time(5, 15) form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), False) self.assertEquals(form.errors['__all__'][0], "Teardown time cannot be after the end time.")
def test_event_date_not_in_future(self): self.postData['setupStartTime_0'] = date(2012, 3, 15) form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), False) self.assertEquals(form.errors['__all__'][0], "Event must be in the future.")
def test_setup_after_event_time(self): self.postData['setupStartTime_1'] = time(5, 15) form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), False) self.assertEquals(form.errors['__all__'][0], "Setup time cannot be after the event time.")
def test_event_after_teardown_date(self): self.postData['eventStartTime_0'] = date(self.year, 3, 15) form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), False) self.assertEquals(form.errors['__all__'][0], "Event time cannot be after the teardown time.")
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 test_empty_datetimes(self): self.postData = { 'name': ['Correct Event'], 'notes': ['Yay!'], 'rooms': ['1'], 'attributes':['2'] } form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), False) self.assertEquals(form.errors['__all__'][0], "A required time field was null")
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])
def test_valid_data(self): form = CreateEventForm(data=self.postData) self.assertEquals(form.is_valid(), True)