Example #1
0
    def test_increment_slots_remaining(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j1.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 0,
                    job = j1)

        s1.save()

        self.assertEqual(s1.slots_remaining, 0)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 1)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 2)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 3)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 4)
Example #2
0
    def test_get_shift_slots_remaining(self):
        """ Test get_shift_slots_remaining(s_id) """

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-12-10", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-6-25", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-1-9", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        self.assertIsNotNone(get_shift_slots_remaining(s1.id))
        self.assertIsNotNone(get_shift_slots_remaining(s2.id))
        self.assertIsNotNone(get_shift_slots_remaining(s3.id))
Example #3
0
    def test_get_event_by_shift_id(self):
        e1 = Event(
                name="Open Source Event",
                start_date="2012-10-22",
                end_date="2012-10-23"
                )

        e1.save()

        j1 = Job(
                name="Software Developer",
                start_date="2012-10-22",
                end_date="2012-10-23",
                description="A software job",
                event=e1
                )

        j2 = Job(
                name="Systems Administrator",
                start_date="2012-9-1",
                end_date="2012-10-26",
                description="A systems administrator job",
                event=e1
                )

        j1.save()
        j2.save()

        s1 = Shift(
                date="2012-10-23",
                start_time="9:00",
                end_time="3:00",
                max_volunteers=1,
                job=j1
                )

        s2 = Shift(
                date="2012-10-23",
                start_time="10:00",
                end_time="4:00",
                max_volunteers=2,
                job=j1
                )

        s3 = Shift(
                date="2012-10-23",
                start_time="12:00",
                end_time="6:00",
                max_volunteers=4,
                job=j2
                )

        s1.save()
        s2.save()
        s3.save()
        
        self.assertIsNotNone(get_event_by_shift_id(s1.id))
        self.assertIsNotNone(get_event_by_shift_id(s2.id))
        self.assertIsNotNone(get_event_by_shift_id(s3.id))
Example #4
0
def create_shift_with_details(shift):
    """
    Creates and returns shift with passed name and dates
    """
    s1 = Shift(date=shift[0],
               start_time=shift[1],
               end_time=shift[2],
               max_volunteers=shift[3],
               job=shift[4])
    s1.save()
    return s1
Example #5
0
def create_shift_with_details(shift):
    """
    Creates and returns shift with passed name and dates
    """
    s1 = Shift(
        date=shift[0],
        start_time=shift[1],
        end_time=shift[2],
        max_volunteers=shift[3],
        job=shift[4]
        )
    s1.save()
    return s1
Example #6
0
def create_shift_with_details(shift):
    """
    Creates and returns shift with passed name and dates
    """

    s1 = Shift(date=shift['date'],
               start_time=shift['start_time'],
               end_time=shift['end_time'],
               max_volunteers=shift['max_volunteers'],
               job=shift['job'],
               address=shift['address'],
               venue=shift['venue'])
    s1.save()
    return s1
Example #7
0
    def test_get_shifts_with_open_slots(self):
        """ Test get_shifts_with_open_slots(j_id) """
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        self.assertIsNotNone(get_shifts_with_open_slots(j1.id))
        self.assertIsNotNone(get_shifts_with_open_slots(j2.id))
Example #8
0
    def get_shifts_ordered_by_date(self):

        e1 = Event(name = "Open Source Event",
                start_date = "2012-10-22",
                end_date = "2012-10-23")

        e1.save()

        j1 = Job(name = "Software Developer",
            start_date = "2012-10-22",
            end_date = "2012-10-23",
            description = "A software job",
            event = e1)

        j1.save()

        s1 = Shift(date = "2012-1-10",
            start_time = "9:00",
            end_time = "3:00",
            max_volunteers = 1,
            job = j1)

        s2 = Shift(date = "2012-6-25",
            start_time = "10:00",
            end_time = "4:00",
            max_volunteers = 2,
            job = j1)

        s3 = Shift(date = "2012-12-9",
            start_time = "12:00",
            end_time = "6:00",
            max_volunteers = 4,
            job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_ordered_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
Example #9
0
    def get_shifts_by_date(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")
        
        j1.save()

        s1 = Shift(date = "2012-1-10",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-6-25",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-12-9",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
Example #10
0
    def test_get_shift_by_id(self):

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        # test typical cases
        self.assertIsNotNone(get_shift_by_id(s1.id))
        self.assertIsNotNone(get_shift_by_id(s2.id))
        self.assertIsNotNone(get_shift_by_id(s3.id))

        self.assertEqual(get_shift_by_id(s1.id), s1)
        self.assertEqual(get_shift_by_id(s2.id), s2)
        self.assertEqual(get_shift_by_id(s3.id), s3)

        # test non-existant cases
        self.assertIsNone(get_shift_by_id(100))
        self.assertIsNone(get_shift_by_id(200))
        self.assertIsNone(get_shift_by_id(300))
        self.assertIsNone(get_shift_by_id(400))

        self.assertNotEqual(get_shift_by_id(100), s1)
        self.assertNotEqual(get_shift_by_id(100), s2)
        self.assertNotEqual(get_shift_by_id(100), s3)
        self.assertNotEqual(get_shift_by_id(200), s1)
        self.assertNotEqual(get_shift_by_id(200), s2)
        self.assertNotEqual(get_shift_by_id(200), s3)
        self.assertNotEqual(get_shift_by_id(300), s1)
        self.assertNotEqual(get_shift_by_id(300), s2)
        self.assertNotEqual(get_shift_by_id(300), s3)
Example #11
0
File: utils.py Project: systers/vms
def create_shift_with_details(shift):
    """
    Creates and returns shift with passed name and dates
    """
    if len(shift) == 5:
        s1 = Shift(
            date=shift[0],
            start_time=shift[1],
            end_time=shift[2],
            max_volunteers=shift[3],
            job=shift[4])
    elif len(shift) == 7:
        s1 = Shift(
            date=shift[0],
            start_time=shift[1],
            end_time=shift[2],
            max_volunteers=shift[3],
            job=shift[4],
            address=shift[5],
            venue=shift[6]
        )
    s1.save()
    return s1
Example #12
0
    def test_delete_shift(self):
        """ Test delete_shift(shift_id) """
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="1:00", end_time="12:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2011-11-11", start_time="11:00", end_time="12:00", max_volunteers=3, job=j1)

        s1.save()
        s2.save()

        self.assertTrue(delete_shift(s1.id))
        self.assertFalse(delete_shift(100))

        register(v1.id, s2.id)
        self.assertFalse(delete_shift(s2.id))
Example #13
0
def create_shift_with_details(shift):
    """
    Creates and returns shift with passed name and dates
    """
    if len(shift) == 5:
        s1 = Shift(date=shift[0],
                   start_time=shift[1],
                   end_time=shift[2],
                   max_volunteers=shift[3],
                   job=shift[4])
    elif len(shift) == 7:
        s1 = Shift(date=shift[0],
                   start_time=shift[1],
                   end_time=shift[2],
                   max_volunteers=shift[3],
                   job=shift[4],
                   address=shift[5],
                   venue=shift[6])
    s1.save()
    return s1
Example #14
0
    def test_get_shift_by_id(self):

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j1.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical cases
        self.assertIsNotNone(get_shift_by_id(s1.id))
        self.assertIsNotNone(get_shift_by_id(s2.id))
        self.assertIsNotNone(get_shift_by_id(s3.id))

        self.assertEqual(get_shift_by_id(s1.id), s1)
        self.assertEqual(get_shift_by_id(s2.id), s2)
        self.assertEqual(get_shift_by_id(s3.id), s3)

        #test non-existant cases
        self.assertIsNone(get_shift_by_id(100))
        self.assertIsNone(get_shift_by_id(200))
        self.assertIsNone(get_shift_by_id(300))
        self.assertIsNone(get_shift_by_id(400))

        self.assertNotEqual(get_shift_by_id(100), s1)
        self.assertNotEqual(get_shift_by_id(100), s2)
        self.assertNotEqual(get_shift_by_id(100), s3)
        self.assertNotEqual(get_shift_by_id(200), s1)
        self.assertNotEqual(get_shift_by_id(200), s2)
        self.assertNotEqual(get_shift_by_id(200), s3)
        self.assertNotEqual(get_shift_by_id(300), s1)
        self.assertNotEqual(get_shift_by_id(300), s2)
        self.assertNotEqual(get_shift_by_id(300), s3)
Example #15
0
    def test_edit_shift_hours(self):

        u1 = User.objects.create_user('Yoshi')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v1.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j1.save()

        s1 = Shift(date="2012-10-23",
                   start_time="1:00",
                   end_time="12:00",
                   max_volunteers=1,
                   job=j1)

        s1.save()

        register(v1.id, s1.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=11, minute=0)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=1, minute=0)
        end_time = datetime.time(hour=4, minute=0)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=4, minute=15)
        end_time = datetime.time(hour=12, minute=35)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=2, minute=5)
        end_time = datetime.time(hour=4, minute=15)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=5, minute=30)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)
Example #16
0
    def test_clear_shift_hours(self):

        u1 = User.objects.create_user('Yoshi')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v1.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        register(v1.id, s1.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(v1.id, s2.id, start_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(v1.id, s3.id, start_time, end_time)

        clear_shift_hours(v1.id, s1.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s1.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s2.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s2.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s3.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id,
                                                     shift_id=s3.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)
Example #17
0
    def test_register(self):

        RESULT_IS_VALID = "IS_VALID"
        ERROR_CODE_ALREADY_SIGNED_UP = "ERROR_CODE_ALREADY_SIGNED_UP"
        ERROR_CODE_NO_SLOTS_REMAINING = "ERROR_CODE_NO_SLOTS_REMAINING"

        u1 = User.objects.create_user('Yoshi')
        u2 = User.objects.create_user('John')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v2 = Volunteer(first_name="John",
                       last_name="Doe",
                       address="7 Alpine Street",
                       city="Maplegrove",
                       state="Wyoming",
                       country="USA",
                       phone_number="23454545",
                       email="*****@*****.**",
                       user=u2)

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        #test typical cases
        register(v1.id, s1.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        #test cases where volunteer tries to sign up for a shift they are already signed up for
        self.assertEqual(register(v1.id, s1.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v1.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v1.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)

        #test case where more than one volunteer signs up for the same shift
        #v2 can't sign up for s1 because there are no slots remaining
        self.assertEqual(register(v2.id, s1.id), ERROR_CODE_NO_SLOTS_REMAINING)

        register(v2.id, s2.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id))

        register(v2.id, s3.id)
        self.assertIsNotNone(
            VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id))

        #test cases where a volunteer tries to sign up for a shift they are already signed up for
        self.assertEqual(register(v2.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v2.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)
Example #18
0
    def test_get_volunteer_shift_by_id(self):

        u1 = User.objects.create_user('Yoshi')
        u2 = User.objects.create_user('John')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v2 = Volunteer(first_name="John",
                       last_name="Doe",
                       address="7 Alpine Street",
                       city="Maplegrove",
                       state="Wyoming",
                       country="USA",
                       phone_number="23454545",
                       email="*****@*****.**",
                       user=u2)

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        #test cases where signed up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        register(v2.id, s1.id)
        register(v2.id, s2.id)
        register(v2.id, s3.id)

        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s1.id),
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))
        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s2.id),
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))
        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s3.id),
            VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        #self.assertEqual(get_volunteer_shift_by_id(v2.id, s1.id), VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s1.id)) #why does this throw DoesNotExist?
        self.assertEqual(
            get_volunteer_shift_by_id(v2.id, s2.id),
            VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id))
        self.assertEqual(
            get_volunteer_shift_by_id(v2.id, s3.id),
            VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id))
Example #19
0
    def test_cancel_shift_registration(self):

        u1 = User.objects.create_user("Yoshi")
        u2 = User.objects.create_user("John")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v2 = Volunteer(
            first_name="John",
            last_name="Doe",
            address="7 Alpine Street",
            city="Maplegrove",
            state="Wyoming",
            country="USA",
            phone_number="23454545",
            email="*****@*****.**",
            user=u2,
        )

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        # test cases when try to cancel when they aren't signed up for a shift
        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s2.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s3.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s2.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s3.id)

        # register volunteers to shifts
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)
        register(v2.id, s1.id)
        register(v2.id, s2.id)
        register(v2.id, s3.id)

        # test typical cases
        cancel_shift_registration(v1.id, s1.id)
        cancel_shift_registration(v1.id, s2.id)
        cancel_shift_registration(v1.id, s3.id)
        # cancel_shift_registration(v2.id, s1.id)
        # why is this throwing ObjectDoesNotExist?
        cancel_shift_registration(v2.id, s2.id)
        cancel_shift_registration(v2.id, s3.id)
Example #20
0
    def test_send_reminder(self):

        u1 = User.objects.create_user("Marina")
        u2 = User.objects.create_user("Anna")

        v1 = Volunteer(
            first_name="Marina",
            last_name="Tsvetaeva",
            address="MyAddress",
            city="MyCity",
            state="MyState",
            country="MyCountry",
            phone_number="2374983247",
            email="*****@*****.**",
            reminder_days=1,
            user=u1,
        )

        v2 = Volunteer(
            first_name="Anna",
            last_name="Akhmatova",
            address="MyAddress",
            city="MyCity",
            state="MyState",
            country="MyCountry",
            phone_number="2374983247",
            email="*****@*****.**",
            reminder_days=7,
            user=u2,
        )
        v1.save()
        v2.save()

        e1 = Event(name="GHC 2015", start_date="2015-07-22", end_date="2015-08-23")

        e1.save()

        j1 = Job(
            name="Volunteer Program Manager",
            start_date="2015-07-22",
            end_date="2015-08-23",
            description="Volunteer Program Manager",
            event=e1,
        )

        j2 = Job(
            name="Volunteer Coordinator",
            start_date="2015-07-22",
            end_date="2015-08-23",
            description="Volunteer Coordinator",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(
            date="2015-08-23",
            start_time="9:00",
            end_time="3:00",
            max_volunteers=1,
            address="Test address",
            city="Atlanta",
            state="Georgia",
            country="USA",
            venue="Near the south entrance",
            job=j1,
        )

        s2 = Shift(
            date=date.today() + timedelta(7),  # one week date
            start_time="10:00",
            end_time="4:00",
            max_volunteers=2,
            address="Test address",
            city="Atlanta",
            state="Georgia",
            country="USA",
            venue="Near the south entrance",
            job=j1,
        )

        s3 = Shift(
            date=date.today() + timedelta(1),  # tomorrow date
            start_time="12:00",
            end_time="6:00",
            max_volunteers=4,
            address="Test address",
            city="Atlanta",
            state="Georgia",
            country="USA",
            venue="Near the south entrance",
            job=j2,
        )

        s1.save()
        s2.save()
        s3.save()

        # sign up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)
        register(v2.id, s1.id)
        register(v2.id, s2.id)
        register(v2.id, s3.id)

        # test typical case

        result = send_reminder()

        self.assertEqual(result, 2)
Example #21
0
    def test_get_volunteer_shift_by_id(self):

        u1 = User.objects.create_user("Yoshi")
        u2 = User.objects.create_user("John")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v2 = Volunteer(
            first_name="John",
            last_name="Doe",
            address="7 Alpine Street",
            city="Maplegrove",
            state="Wyoming",
            country="USA",
            phone_number="23454545",
            email="*****@*****.**",
            user=u2,
        )

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        # test cases where signed up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        register(v2.id, s1.id)
        register(v2.id, s2.id)
        register(v2.id, s3.id)

        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s1.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        )
        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s2.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id)
        )
        self.assertEqual(
            get_volunteer_shift_by_id(v1.id, s3.id), VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id)
        )

        # self.assertEqual(get_volunteer_shift_by_id(v2.id, s1.id),
        # VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s1.id))
        # why does this throw DoesNotExist?
        self.assertEqual(
            get_volunteer_shift_by_id(v2.id, s2.id), VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id)
        )
        self.assertEqual(
            get_volunteer_shift_by_id(v2.id, s3.id), VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id)
        )
Example #22
0
    def test_generate_report(self):
        """ Tests test_generate_report(volunteer_shift_list) """
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        shift_list = [s1, s2, s3]

        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        # register will return an exception on error
        # (such as when invalid parameters are passed)
        # if an exception does get raised, this test will automatically fail
        register(v1.id, s1.id)
        volunteer_shift_1 = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift_1)

        register(v1.id, s2.id)
        volunteer_shift_2 = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id)
        self.assertIsNotNone(volunteer_shift_2)

        register(v1.id, s3.id)
        volunteer_shift_3 = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id)
        self.assertIsNotNone(volunteer_shift_3)

        volunteer_shift_list = [volunteer_shift_1, volunteer_shift_2, volunteer_shift_3]

        self.assertIsNotNone(generate_report(volunteer_shift_list))
Example #23
0
    def test_edit_shift_hours(self):
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="1:00", end_time="12:00", max_volunteers=1, job=j1)

        s1.save()

        register(v1.id, s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=11, minute=0)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=1, minute=0)
        end_time = datetime.time(hour=4, minute=0)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=4, minute=15)
        end_time = datetime.time(hour=12, minute=35)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=2, minute=5)
        end_time = datetime.time(hour=4, minute=15)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=5, minute=30)
        edit_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNotNone(volunteer_shift.start_time)
        self.assertIsNotNone(volunteer_shift.end_time)
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)
Example #24
0
    def get_shifts_ordered_by_date(self):

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j1.save()

        s1 = Shift(date="2012-1-10",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-6-25",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-12-9",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_ordered_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
Example #25
0
    def test_get_unlogged_shifts_by_volunteer_id(self):

        u1 = User.objects.create_user('Yoshi')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v1.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        #sign up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        #test typical case
        shift_list = get_unlogged_shifts_by_volunteer_id(v1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)
Example #26
0
    def test_has_slots_remaining(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")
        
        j1.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-10-23",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-10-23",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j1)

        s1.save()
        s2.save()
        s3.save()

        self.assertTrue(has_slots_remaining(s1))
        self.assertTrue(has_slots_remaining(s2))
        self.assertTrue(has_slots_remaining(s3))

        decrement_slots_remaining(s1)
        self.assertFalse(has_slots_remaining(s1))

        decrement_slots_remaining(s2)
        self.assertTrue(has_slots_remaining(s2))
        decrement_slots_remaining(s2)
        self.assertFalse(has_slots_remaining(s2))

        decrement_slots_remaining(s3)
        self.assertTrue(has_slots_remaining(s3))
        decrement_slots_remaining(s3)
        self.assertTrue(has_slots_remaining(s3))
        decrement_slots_remaining(s3)
        self.assertTrue(has_slots_remaining(s3))
        decrement_slots_remaining(s3)
        self.assertFalse(has_slots_remaining(s3))

        self.assertEqual(s1.slots_remaining, 0)
        self.assertEqual(s2.slots_remaining, 0)
        self.assertEqual(s3.slots_remaining, 0)
Example #27
0
    def test_is_signed_up(self):

        u1 = User.objects.create_user('Yoshi')
        u2 = User.objects.create_user('John')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v2 = Volunteer(first_name="John",
                       last_name="Doe",
                       address="7 Alpine Street",
                       city="Maplegrove",
                       state="Wyoming",
                       country="USA",
                       phone_number="23454545",
                       email="*****@*****.**",
                       user=u2)

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        #test cases where not signed up yet
        self.assertFalse(is_signed_up(v1.id, s1.id))
        self.assertFalse(is_signed_up(v1.id, s2.id))
        self.assertFalse(is_signed_up(v1.id, s3.id))

        #test cases where signed up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        self.assertTrue(is_signed_up(v1.id, s1.id))
        self.assertTrue(is_signed_up(v1.id, s2.id))
        self.assertTrue(is_signed_up(v1.id, s3.id))

        #test case where more than one volunteer signs up for the same shift
        self.assertFalse(is_signed_up(v2.id, s1.id))
        self.assertFalse(is_signed_up(v2.id, s2.id))
        self.assertFalse(is_signed_up(v2.id, s3.id))

        register(v2.id, s2.id)
        register(v2.id, s3.id)

        self.assertFalse(is_signed_up(v2.id, s1.id))
        self.assertTrue(is_signed_up(v2.id, s2.id))
        self.assertTrue(is_signed_up(v2.id, s3.id))
Example #28
0
    def test_register(self):

        u1 = User.objects.create_user('Yoshi')     
        u2 = User.objects.create_user('John')     

        v1 = Volunteer(first_name = "Yoshi",
                        last_name = "Turtle",
                        address = "Mario Land",
                        city = "Nintendo Land",
                        state = "Nintendo State",
                        country = "Nintendo Nation",
                        phone_number = "2374983247",
                        email = "*****@*****.**",
                        user = u1)

        v2 = Volunteer(first_name = "John",
                        last_name = "Doe",
                        address = "7 Alpine Street",
                        city = "Maplegrove",
                        state = "Wyoming",
                        country = "USA",
                        phone_number = "23454545",
                        email = "*****@*****.**",
                        user = u2)

        v1.save()
        v2.save()

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j2 = Job(job_title = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job")
        
        j1.save()
        j2.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-10-23",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-10-23",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j2)

        s1.save()
        s2.save()
        s3.save()
    
        #test typical cases
        self.assertTrue(register(v1.id, s1.id))
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        self.assertTrue(register(v1.id, s2.id))
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        self.assertTrue(register(v1.id, s3.id))
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        #test cases where volunteer tries to sign up for a shift they are already signed up for
        self.assertFalse(register(v1.id, s1.id))
        self.assertFalse(register(v1.id, s2.id))
        self.assertFalse(register(v1.id, s3.id))

        #test case where more than one volunteer signs up for the same shift
        #v2 can't sign up for s1 because there are no slots remaining
        self.assertFalse(register(v2.id, s1.id))

        self.assertTrue(register(v2.id, s2.id))
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id))

        self.assertTrue(register(v2.id, s3.id))
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id))

        #test cases where a volunteer tries to sign up for a shift they are already signed up for
        self.assertFalse(register(v2.id, s2.id))
        self.assertFalse(register(v2.id, s3.id))        
Example #29
0
    def test_get_shift_by_id(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")
        
        j1.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-10-23",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-10-23",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical cases
        self.assertIsNotNone(get_shift_by_id(s1.id))
        self.assertIsNotNone(get_shift_by_id(s2.id))
        self.assertIsNotNone(get_shift_by_id(s3.id))

        self.assertEqual(get_shift_by_id(s1.id), s1)
        self.assertEqual(get_shift_by_id(s2.id), s2)
        self.assertEqual(get_shift_by_id(s3.id), s3)

        #test non-existant cases
        self.assertIsNone(get_shift_by_id(100))
        self.assertIsNone(get_shift_by_id(200))
        self.assertIsNone(get_shift_by_id(300))
        self.assertIsNone(get_shift_by_id(400))

        self.assertNotEqual(get_shift_by_id(100), s1)
        self.assertNotEqual(get_shift_by_id(100), s2)
        self.assertNotEqual(get_shift_by_id(100), s3)
        self.assertNotEqual(get_shift_by_id(200), s1)
        self.assertNotEqual(get_shift_by_id(200), s2)
        self.assertNotEqual(get_shift_by_id(200), s3)
        self.assertNotEqual(get_shift_by_id(300), s1)
        self.assertNotEqual(get_shift_by_id(300), s2)
        self.assertNotEqual(get_shift_by_id(300), s3)
Example #30
0
    def test_register(self):

        ERROR_CODE_ALREADY_SIGNED_UP = "ERROR_CODE_ALREADY_SIGNED_UP"
        ERROR_CODE_NO_SLOTS_REMAINING = "ERROR_CODE_NO_SLOTS_REMAINING"

        u1 = User.objects.create_user("Yoshi")
        u2 = User.objects.create_user("John")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v2 = Volunteer(
            first_name="John",
            last_name="Doe",
            address="7 Alpine Street",
            city="Maplegrove",
            state="Wyoming",
            country="USA",
            phone_number="23454545",
            email="*****@*****.**",
            user=u2,
        )

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        # test typical cases
        register(v1.id, s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        # test cases where volunteer tries to sign up for a shift
        # they are already signed up for
        self.assertEqual(register(v1.id, s1.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v1.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v1.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)

        # test case where more than one volunteer signs up for the same shift
        # v2 can't sign up for s1 because there are no slots remaining
        self.assertEqual(register(v2.id, s1.id), ERROR_CODE_NO_SLOTS_REMAINING)

        register(v2.id, s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s2.id))

        register(v2.id, s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v2.id, shift_id=s3.id))

        # test cases where a volunteer tries to sign up for a shift
        # they are already signed up for
        self.assertEqual(register(v2.id, s2.id), ERROR_CODE_ALREADY_SIGNED_UP)
        self.assertEqual(register(v2.id, s3.id), ERROR_CODE_ALREADY_SIGNED_UP)
Example #31
0
    def test_get_shifts_signed_up_for(self):

        u1 = User.objects.create_user('Yoshi')     

        v1 = Volunteer(first_name = "Yoshi",
                        last_name = "Turtle",
                        address = "Mario Land",
                        city = "Nintendo Land",
                        state = "Nintendo State",
                        country = "Nintendo Nation",
                        phone_number = "2374983247",
                        email = "*****@*****.**",
                        user = u1)

        v1.save()

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j2 = Job(job_title = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job")
        
        j1.save()
        j2.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-10-23",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-10-23",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j2)

        s1.save()
        s2.save()
        s3.save()
    
        #sign up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        #test typical case
        shift_list = get_shifts_signed_up_for(v1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)
Example #32
0
    def test_clear_shift_hours(self):

        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        register(v1.id, s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(v1.id, s2.id, start_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(v1.id, s3.id, start_time, end_time)

        clear_shift_hours(v1.id, s1.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s2.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)

        clear_shift_hours(v1.id, s3.id)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id)
        self.assertIsNone(volunteer_shift.start_time)
        self.assertIsNone(volunteer_shift.end_time)
Example #33
0
    def test_get_unlogged_shifts_by_volunteer_id(self):

        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        # sign up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        # test typical case
        shift_list = get_unlogged_shifts_by_volunteer_id(v1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)
Example #34
0
    def test_cancel_shift_registration(self):

        u1 = User.objects.create_user('Yoshi')
        u2 = User.objects.create_user('John')

        v1 = Volunteer(first_name="Yoshi",
                       last_name="Turtle",
                       address="Mario Land",
                       city="Nintendo Land",
                       state="Nintendo State",
                       country="Nintendo Nation",
                       phone_number="2374983247",
                       email="*****@*****.**",
                       user=u1)

        v2 = Volunteer(first_name="John",
                       last_name="Doe",
                       address="7 Alpine Street",
                       city="Maplegrove",
                       state="Wyoming",
                       country="USA",
                       phone_number="23454545",
                       email="*****@*****.**",
                       user=u2)

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event",
                   start_date="2012-10-22",
                   end_date="2012-10-23")

        e1.save()

        j1 = Job(name="Software Developer",
                 start_date="2012-10-22",
                 end_date="2012-10-23",
                 description="A software job",
                 event=e1)

        j2 = Job(name="Systems Administrator",
                 start_date="2012-9-1",
                 end_date="2012-10-26",
                 description="A systems administrator job",
                 event=e1)

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23",
                   start_time="9:00",
                   end_time="3:00",
                   max_volunteers=1,
                   job=j1)

        s2 = Shift(date="2012-10-23",
                   start_time="10:00",
                   end_time="4:00",
                   max_volunteers=2,
                   job=j1)

        s3 = Shift(date="2012-10-23",
                   start_time="12:00",
                   end_time="6:00",
                   max_volunteers=4,
                   job=j2)

        s1.save()
        s2.save()
        s3.save()

        #test cases when try to cancel when they aren't signed up for a shift
        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s2.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v1.id, s3.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s1.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s2.id)

        with self.assertRaises(ObjectDoesNotExist):
            cancel_shift_registration(v2.id, s3.id)

        #register volunteers to shifts
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)
        register(v2.id, s1.id)
        register(v2.id, s2.id)
        register(v2.id, s3.id)

        #test typical cases
        cancel_shift_registration(v1.id, s1.id)
        cancel_shift_registration(v1.id, s2.id)
        cancel_shift_registration(v1.id, s3.id)
        #cancel_shift_registration(v2.id, s1.id) #why is this throwing ObjectDoesNotExist?
        cancel_shift_registration(v2.id, s2.id)
        cancel_shift_registration(v2.id, s3.id)
Example #35
0
    def test_add_shift_hours(self):

        u1 = User.objects.create_user('Yoshi')     

        v1 = Volunteer(first_name = "Yoshi",
                    last_name = "Turtle",
                    address = "Mario Land",
                    city = "Nintendo Land",
                    state = "Nintendo State",
                    country = "Nintendo Nation",
                    phone_number = "2374983247",
                    email = "*****@*****.**",
                    user = u1)

        v1.save()

        e1 = Event(name = "Open Source Event",
                start_date = "2012-10-22",
                end_date = "2012-10-23")

        e1.save()

        j1 = Job(name = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job",
                event = e1)

        j2 = Job(name = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job",
                event = e1)

        j1.save()
        j2.save()

        s1 = Shift(date = "2012-10-23",
                start_time = "9:00",
                end_time = "3:00",
                max_volunteers = 1,
                job = j1)

        s2 = Shift(date = "2012-10-23",
                start_time = "10:00",
                end_time = "4:00",
                max_volunteers = 2,
                job = j1)

        s3 = Shift(date = "2012-10-23",
                start_time = "12:00",
                end_time = "6:00",
                max_volunteers = 4,
                job = j2)

        s1.save()
        s2.save()
        s3.save()

        #register will return an exception on error (such as when invalid parameters are passed)
        #if an exception does get raised, this test will automatically fail
        register(v1.id, s1.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id))

        register(v1.id, s2.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id))

        register(v1.id, s3.id)
        self.assertIsNotNone(VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id))

        start_time = datetime.time(hour=9, minute=0)
        end_time = datetime.time(hour=10, minute=0)
        add_shift_hours(v1.id, s1.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s1.id);
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=10, minute=0)
        end_time = datetime.time(hour=12, minute=0)
        add_shift_hours(v1.id, s2.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s2.id);
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)

        start_time = datetime.time(hour=5, minute=0)
        end_time = datetime.time(hour=6, minute=0)
        add_shift_hours(v1.id, s3.id, start_time, end_time)
        volunteer_shift = VolunteerShift.objects.get(volunteer_id=v1.id, shift_id=s3.id);
        self.assertEqual(volunteer_shift.start_time, start_time)
        self.assertEqual(volunteer_shift.end_time, end_time)
Example #36
0
    def test_is_signed_up(self):

        u1 = User.objects.create_user("Yoshi")
        u2 = User.objects.create_user("John")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="*****@*****.**",
            user=u1,
        )

        v2 = Volunteer(
            first_name="John",
            last_name="Doe",
            address="7 Alpine Street",
            city="Maplegrove",
            state="Wyoming",
            country="USA",
            phone_number="23454545",
            email="*****@*****.**",
            user=u2,
        )

        v1.save()
        v2.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        # test cases where not signed up yet
        self.assertFalse(is_signed_up(v1.id, s1.id))
        self.assertFalse(is_signed_up(v1.id, s2.id))
        self.assertFalse(is_signed_up(v1.id, s3.id))

        # test cases where signed up
        register(v1.id, s1.id)
        register(v1.id, s2.id)
        register(v1.id, s3.id)

        self.assertTrue(is_signed_up(v1.id, s1.id))
        self.assertTrue(is_signed_up(v1.id, s2.id))
        self.assertTrue(is_signed_up(v1.id, s3.id))

        # test case where more than one volunteer signs up for the same shift
        self.assertFalse(is_signed_up(v2.id, s1.id))
        self.assertFalse(is_signed_up(v2.id, s2.id))
        self.assertFalse(is_signed_up(v2.id, s3.id))

        register(v2.id, s2.id)
        register(v2.id, s3.id)

        self.assertFalse(is_signed_up(v2.id, s1.id))
        self.assertTrue(is_signed_up(v2.id, s2.id))
        self.assertTrue(is_signed_up(v2.id, s3.id))