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__isDuplicateEvent_false(self):
        event1 = models.Event.query.first()

        event2 = models.Event()
        event2.name = event1.name + 'differenttext'
        event2.startdate = event1.startdate
        event2.enddate = event1.enddate
        event2.organizationFK = event1.organizationFK

        result = events._isDuplicateEvent(event2)
        self.assertFalse(result)
 def test__isDuplicateEvent_true(self):
     event1 = models.Event.query.first()
     
     event2 = models.Event()
     event2.name = event1.name
     event2.startdate = event1.startdate
     event2.enddate = event1.enddate
     event2.organizationFK = event1.organizationFK
     
     result = events._isDuplicateEvent(event2)
     self.assertTrue(result)
    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__removeEvent_invalid(self):
     # Define the values we're going to have to add for the test.
     newEvent = models.Event()
     name = 'test__removeEvent_invalid event'
     desc = 'description of test__removeEvent_invalid 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)
     
     # Try to delete it even though we know it's not there
     result = events._removeEvent(newEvent.pk, self.db)
     self.assertFalse(result)