def test__getEventByID(self):
        event = events._getEventByID(1)
        self.assertIsNotNone(event)
        self.assertEqual(event.name, 'My Event')
        self.assertEqual(event.description, 'This is my event')
        self.assertEqual(event.organizationFK, 1)

        event = events._getEventByID(2)
        self.assertIsNotNone(event)
        self.assertEqual(event.name, 'Your Event')
        self.assertEqual(event.description, 'This is your event')
        self.assertEqual(event.organizationFK, 2)

        event = events._getEventByID(999)
        self.assertIsNone(event)
Exemplo n.º 2
0
def _insertShift(shift, db):
    result = "Unknown"
    isDup = _isDuplicateShift(shift)
    event = events._getEventByID(shift.eventFK)
    if event is None:
        result = "BadEvent"
    if isDup == False and result == "Unknown":
        db.session.add(shift)
        db.session.commit()
        if shift.pk > 0:
            result = shift.pk
    if result == "Unknown":
        result = "Duplicate"
    return result