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)
Beispiel #2
0
def removeShiftFromEvent(org_id, event_id, shift_id):
    try:
        result = shifts_controller.removeShift(event_id, db)
        return Response(response=result, mimetype='application/json')
    except Exception, e:
        return abort(404)