def test_removeShift_true(self):
     # Define the values we're going to have to add for the test.
     newShift = models.Shift()
     newShift.eventFK = 1
     newShift.startdatetime = datetime.datetime(2013,7,28,16,0)
     newShift.enddatetime = datetime.datetime(2013,7,28,17,0)
     newShift.location = 'Booth C.5'
     newShift.minWorkers = 24
     newShift.maxWorkers = 42
     
     # Ensure it's not already in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertFalse(result)
     
     # Add it to db
     newShiftPK = shifts_controller._insertShift(newShift, self.db)
     self.assertTrue(newShiftPK > 0)
     
     # Ensure it's in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertTrue(result)
     
     # Now that we added it, lets delete it.
     result = shifts_controller.removeShift(newShiftPK, 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.SHIFT_PK_KEY:
             self.assertEqual(value, newShiftPK)
     
     # Ensure it's not in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertFalse(result)
 def test__removeShift_true(self):
     # Define the values we're going to have to add for the test.
     newShift = models.Shift()
     newShift.eventFK = 1
     newShift.startdatetime = datetime.datetime(2013,7,28,16,0)
     newShift.enddatetime = datetime.datetime(2013,7,28,17,0)
     newShift.location = 'Booth C.5'
     newShift.minWorkers = 24
     newShift.maxWorkers = 42
     
     # Ensure it's not already in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertFalse(result)
     
     # Add it to db
     newShiftPK = shifts_controller._insertShift(newShift, self.db)
     self.assertTrue(newShiftPK > 0)
     
     # Ensure it's in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertTrue(result)
     
     # Now that we added it, lets delete it.
     result = shifts_controller._removeShift(newShiftPK, self.db)
     self.assertTrue(result)
     
     # Ensure it's not in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertFalse(result)
    def test__isDuplicateShift_false(self):
        shift1 = models.Shift.query.first()

        shift2 = models.Shift()
        shift2.eventFK = shift1.eventFK
        shift2.startdatetime = shift1.startdatetime
        shift2.enddatetime = shift1.enddatetime
        shift2.location = shift1.location + 'difference'

        result = shifts_controller._isDuplicateShift(shift2)
        self.assertFalse(result)
 def test__removeShift_invalid(self):
     # Define the values we're going to have to add for the test.
     newShift = models.Shift()
     newShift.eventFK = 1
     newShift.startdatetime = datetime.datetime(2013,7,28,16,0)
     newShift.enddatetime = datetime.datetime(2013,7,28,17,0)
     newShift.location = 'Booth C.5'
     newShift.minWorkers = 24
     newShift.maxWorkers = 42
     
     # Ensure it's not already in db.
     result = shifts_controller._isDuplicateShift(newShift)
     self.assertFalse(result)
     
     # Try to delete it even though we know it's not there
     result = shifts_controller._removeShift(newShift.pk, self.db)
     self.assertFalse(result)