def test__removeEvent_true(self): # Define the values we're going to have to add for the test. newEvent = models.Event() name = 'test__removeEvent_true event' desc = 'description of test__removeEvent_true event is indescribable' start = datetime.datetime(2013, 3, 20, 1, 0) end = datetime.datetime(2013, 3, 20, 2, 0) orgFK = 1 newEvent.name = name newEvent.description = desc newEvent.startdate = start newEvent.enddate = end newEvent.organizationFK = orgFK # Ensure it's not already in db. result = events._isDuplicateEvent(newEvent) self.assertFalse(result) # Add it to db newEventPK = events._insertEvent(newEvent, self.db) self.assertTrue(newEventPK > 0) # Ensure it's in db. result = events._isDuplicateEvent(newEvent) self.assertTrue(result) # Now that we added it, lets delete it. result = events._removeEvent(newEventPK, self.db) self.assertTrue(result) # Ensure it's not in db. result = events._isDuplicateEvent(newEvent) self.assertFalse(result)
def test__insertEvent_badorg(self): event = models.Event() name='My Event' desc='This is my event' start=datetime.datetime(2013, 7, 12, 12, 0) end=datetime.datetime(2013, 7, 14, 16, 0) orgFK=0 event.name = name event.description = desc event.startdate = start event.enddate = end event.organizationFK = orgFK result = events._insertEvent(event, self.db) self.assertEqual(result, 'BadOrg')
def test_removeEvent_true(self): # Define the values we're going to have to add for the test. newEvent = models.Event() name = 'test_removeEvent_true event' desc = 'description of test_removeEvent_true event is indescribable' start = datetime.datetime(2013, 3, 20, 1, 0) end = datetime.datetime(2013, 3, 20, 2, 0) orgFK = 2 newEvent.name = name newEvent.description = desc newEvent.startdate = start newEvent.enddate = end newEvent.organizationFK = orgFK # Ensure it's not already in db. result = events._isDuplicateEvent(newEvent) self.assertFalse(result) # Add it to db newEventPK = events._insertEvent(newEvent, self.db) self.assertTrue(newEventPK > 0) # Ensure it's in db. result = events._isDuplicateEvent(newEvent) self.assertTrue(result) # Now that we added it, lets delete it. result = events.removeEvent(newEventPK, self.db) self.assertIsNotNone(result) resultDict = json.loads(result) for key,value in resultDict.iteritems(): if key == 'success': self.assertEqual(value, 'true') if key == models.EVENT_PK_KEY: self.assertEqual(value, newEventPK) # Ensure it's not in db. result = events._isDuplicateEvent(newEvent) self.assertFalse(result)
def test__insertEvent_true(self): event = models.Event() name = 'test__insertEvent_true event' desc = 'description of test__insertEvent_true event is indescribable' start = datetime.datetime(2013, 3, 20, 1, 0) end = datetime.datetime(2013, 3, 20, 2, 0) orgFK = 1 event.name = name event.description = desc event.startdate = start event.enddate = end event.organizationFK = orgFK result = events._insertEvent(event, self.db) self.assertTrue(result > 0) newEvent = models.Event.query.filter_by(pk=result).first() self.assertEqual(newEvent.pk, result) self.assertEqual(newEvent.name, name) self.assertEqual(newEvent.description, desc) self.assertEqual(newEvent.startdate, start) self.assertEqual(newEvent.enddate, end) self.assertEqual(newEvent.organizationFK, orgFK)