Example #1
0
    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)
Example #2
0
    def testInvalidDateFormatEvent(self):
        startTime = "9/24/2010 5:03"
        endTime = "9/24/2044 5:03:29 PM"

        form_data = {
            "name": "Test Event",
            "description": "Event Description",
            "contact_email": "*****@*****.**",
            "start_time": str(startTime),
            "end_time": str(endTime),
            "location": "Berkeley",
        }

        form = AddEventForm(self.user, form_data)
        self.assertFalse(form.is_valid())
Example #3
0
    def testNoEmailEvent(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,
            "start_time": str(startTime),
            "end_time": str(endTime),
            "location": "Berkeley",
        }

        form = AddEventForm(self.user, form_data)
        self.assertFalse(form.is_valid())
Example #4
0
    def testNameTooLongEvent(self):
        startTime = "9/24/2040 5:03:29 PM"
        endTime = "9/24/2050 5:03:29 PM"

        form_data = {
            "name": "a" * 129,
            "description": "Event Description",
            "contact_email": "*****@*****.**",
            "start_time": str(startTime),
            "end_time": str(endTime),
            "organization": self.club.id,
        }

        form = AddEventForm(self.user, form_data)
        self.assertFalse(form.is_valid())
Example #5
0
    def testEmailTooLongEvent(self):
        startTime = "9/24/2040 5:03:29 PM"
        endTime = "9/24/2050 5:03:29 PM"

        email = ("a" * 120) + "@test.com"

        form_data = {
            "name": "",
            "description": "Event Description",
            "organization": self.club.id,
            "contact_email": email,
            "start_time": str(startTime),
            "end_time": str(endTime),
            "location": "Berkeley",
        }

        form = AddEventForm(self.user, form_data)
        self.assertFalse(form.is_valid())
Example #6
0
    def testEventNotAdmin(self):
        test_user_to_organization = UserToOrganization.objects.get(user=self.user);
        test_user_to_organization.delete();

        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.assertFalse(form.is_valid(), form.errors.as_text);  
Example #7
0
    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 == "*****@*****.**")