def test_removeShiftPerson_true(self):
     # Define the values we're going to have to add for the test.
     shiftFK = 3
     personFK = 4
     newShiftPerson = models.ShiftPerson(shiftFK, personFK)
     
     # Ensure it's not already in db.
     result = shiftperson_controller._isDuplicateAssignment(newShiftPerson)
     self.assertFalse(result)
     
     # Add it to db
     newShiftPersonPK = shiftperson_controller._insertShiftPerson(newShiftPerson, self.db)
     self.assertTrue(newShiftPersonPK > 0)
     
     # Ensure it's in db.
     result = shiftperson_controller._isDuplicateAssignment(newShiftPerson)
     self.assertTrue(result)
     
     # Now that we added it, lets delete it.
     result = shiftperson_controller.removeShiftPerson(shiftFK, personFK, 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.SHIFTPERSON_PK_KEY:
             self.assertEqual(value, newShiftPersonPK)
     
     # Ensure it's not in db.
     result = shiftperson_controller._isDuplicateAssignment(newShiftPerson)
     self.assertFalse(result)
Exemple #2
0
def removePersonsFromOrgEventShift(org_id, event_id, shift_id, person_id):
    try:

        if is_request_json():
            removeWorker = shiftperson_controller.removeShiftPerson(shift_id, person_id, db)

            return Response(response=removeWorker, mimetype='application/json')
            
    except Exception, e:
        return abort(404)