예제 #1
0
    def test_edit_request_email_volunteer(self):
        """
        checks if the volunteer gets an email when his hours are edited
        by admin upon his request
        """

        volunteer_1 = create_volunteer()

        shift = {
            'date': '2050-05-20',
            'start_time': '09:00',
            'end_time': '15:00',
            'max_volunteers': '1',
            'address': 'shift-address',
            'venue': 'venue-address',
        }
        shift_1 = self.create_shift(shift)
        start = datetime.time(hour=10, minute=0)
        end = datetime.time(hour=14, minute=0)
        logged_shift = log_hours_with_details(volunteer_1, shift_1, start, end)
        start_time = datetime.time(hour=9, minute=30)
        end_time = datetime.time(hour=14, minute=0)
        edit_request = \
            create_edit_request_with_details(start_time, end_time, logged_shift)
        vol_email = volunteer_1.email
        mail.outbox = []
        mail.send_mail("Log Hours Edited", "message",
                       "*****@*****.**", [vol_email])
        self.assertEqual(len(mail.outbox), 1)
        msg = mail.outbox[0]
        self.assertEqual(msg.subject, "Log Hours Edited")
        self.assertEqual(msg.to, ['*****@*****.**'])
예제 #2
0
    def test_shift_edit_request(self):
        """
        checks the edit request link received by admin
        """

        volunteer_1 = create_volunteer()

        shift = {
            'date': '2050-05-20',
            'start_time': '09:00',
            'end_time': '15:00',
            'max_volunteers': '1',
            'address': 'shift-address',
            'venue': 'venue-address',
        }
        shift_1 = self.create_shift(shift)
        start = datetime.time(hour=10, minute=0)
        end = datetime.time(hour=14, minute=0)
        logged_shift = log_hours_with_details(volunteer_1, shift_1, start, end)
        start_time = datetime.time(hour=9, minute=30)
        end_time = datetime.time(hour=14, minute=0)
        edit_request = \
            create_edit_request_with_details(start_time, end_time, logged_shift)
        response = self.client.get(
            reverse('shift:edit_request_manager',
                    args=[shift_1.id, volunteer_1.id, edit_request.id]))
        self.assertEqual(response.status_code, 302)
예제 #3
0
 def create_edit_request(volunteer, shift):
     """
     Utility function to create a valid edit request.
     :param volunteer: The volunteer who makes a request for editing hours
     :param shift: Volunteer's logged shift which is to be edited
     :return: EditRequest type object
     """
     start = datetime.time(hour=9, minute=0, second=0)
     end = datetime.time(hour=12, minute=0, second=0)
     logged_shift = log_hours_with_details(volunteer, shift, start, end)
     start_time = datetime.time(hour=10, minute=0, second=0)
     end_time = datetime.time(hour=12, minute=0, second=0)
     return create_edit_request_with_details(start_time, end_time, logged_shift)
예제 #4
0
    def test_shift_edit_request(self):
        """
        checks the edit request link received by admin
        """
        org_obj = create_organization_with_details(self.org_name)
        volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj)

        shift = ['09:00', '15:00', '1']
        shift_1 = self.create_shift(shift)
        start = datetime.time(hour=10, minute=0)
        end = datetime.time(hour=14, minute=0)
        logged_shift = log_hours_with_details(volunteer_1, shift_1, start, end)
        start_time = datetime.time(hour=9, minute=30)
        end_time = datetime.time(hour=14, minute=0)
        edit_request = create_edit_request_with_details(start_time, end_time, logged_shift)
        response = self.client.get(reverse('shift:edit_request_manager', args=[shift_1.id, volunteer_1.id, edit_request.id]))
        self.assertEqual(response.status_code, 302)
예제 #5
0
    def test_edit_request_email_volunteer(self):
        """
        checks if the volunteer gets an email when his hours are edited
        by admin upon his request
        """
        org_obj = create_organization_with_details(self.org_name)
        volunteer_1 = create_volunteer_with_details(self.volunteer_1, org_obj)

        shift = ['09:00', '15:00', '1']
        shift_1 = self.create_shift(shift)
        start = datetime.time(hour=10, minute=0)
        end = datetime.time(hour=14, minute=0)
        logged_shift = log_hours_with_details(volunteer_1, shift_1, start, end)
        start_time = datetime.time(hour=9, minute=30)
        end_time = datetime.time(hour=14, minute=0)
        edit_request = create_edit_request_with_details(start_time, end_time, logged_shift)
        vol_email = volunteer_1.email
        mail.outbox = []
        mail.send_mail("Log Hours Edited", "message", "*****@*****.**", [vol_email])
        self.assertEqual(len(mail.outbox), 1)
        msg = mail.outbox[0]
        self.assertEqual(msg.subject, "Log Hours Edited")
        self.assertEqual(msg.to, ['*****@*****.**'])