def testValidEvent5(self): startTime = "9/24/2040 5:03:29 PM" endTime = "9/24/2050 5:03:29 PM" email_128 = ("a" * 119) + "@test.com" self.assertTrue(len(email_128) == 128) form_data = { "name": "Test Event", "description": "Event Description", "contact_email": email_128, "start_time": str(startTime), "end_time": str(endTime), "organization": self.club.id, } form = AddEventForm(self.user, form_data) self.assertTrue(form.is_valid(), form.errors) form.save() test_event = Event.objects.get(name="Test Event") self.assertTrue(test_event.name == "Test Event") self.assertTrue(test_event.description == "Event Description") self.assertTrue(test_event.contact_email == email_128)
def testValidEvent2(self): startTime = "9/24/2040 5:03:29 PM" endTime = "9/24/2050 5:03:29 PM" form_data = { "name": "Test Event", "contact_email": "*****@*****.**", "start_time": str(startTime), "end_time": str(endTime), "organization": self.club.id, "location": "Berkeley", } form = AddEventForm(self.user, form_data) self.assertTrue(form.is_valid(), form.errors) form.save() test_event = Event.objects.get(name="Test Event") self.assertTrue(test_event.name == "Test Event") self.assertTrue(test_event.location == "Berkeley") self.assertTrue(test_event.contact_email == "*****@*****.**")
def testEventAdmin(self): startTime = '9/24/2040 5:03:29 PM' endTime = '9/24/2050 5:03:29 PM' form_data = { 'name': 'Test Event', 'description': 'Event Description', 'organization': self.club.id, 'contact_email': '*****@*****.**', 'start_time': str(startTime), 'end_time': str(endTime), 'location': 'Berkeley', }; form = AddEventForm(self.user, form_data); self.assertTrue(form.is_valid(), form.errors.as_text); form.save(); test_event = Event.objects.get(name="Test Event"); test_user_to_organization = UserToOrganization.objects.get(user=self.user); self.assertTrue(test_user_to_organization.organization == self.club); self.assertTrue(test_user_to_organization.admin == True);