def _insertEvent(event, db): result = 'Unknown' isDup = _isDuplicateEvent(event) org = controllers._getOrganizationByID(event.organizationFK) if org is None: result = 'BadOrg' if(isDup == False and result == 'Unknown'): db.session.add(event) db.session.commit() if(event.pk > 0): result = event.pk shifts_controller.autoGenerateShifts(event.pk, event.startdate, event.enddate, 60, db) if(result == 'Unknown'): result = 'Duplicate' return result
def test__getOrganizationByID(self): org = controllers._getOrganizationByID(1) self.assertIsNotNone(org) self.assertEqual(org.entityFK, 1) self.assertEquals(org.name, 'Ai-Kon') self.assertEquals(org.description, 'Ai-Kon Anime Convention') self.assertEquals(org.entity.type, models.TYPE_ORGANIZATION) self.assertEquals(org.entity.addresses[0].address1, '123 Vroom Street') self.assertEquals(org.entity.addresses[0].address2, None) self.assertEquals(org.entity.addresses[0].address3, None) self.assertEquals(org.entity.addresses[0].city, 'Winnipeg') self.assertEquals(org.entity.addresses[0].province, 'Manitoba') self.assertEquals(org.entity.addresses[0].country, 'Canada') self.assertEquals(org.entity.addresses[0].postalcode, 'A1A1A1') self.assertEquals(org.entity.addresses[0].isprimary, True) self.assertEquals(org.entity.contacts[0].type, models.TYPE_EMAIL) self.assertEquals(org.entity.contacts[0].value, '*****@*****.**') self.assertEquals(org.entity.contacts[0].isprimary, True)