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)
 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.assertTrue(result)
     
     # Ensure it's not in db.
     result = shiftperson_controller._isDuplicateAssignment(newShiftPerson)
     self.assertFalse(result)
 def test__insertShiftPerson_true(self):
     shiftFK = 1
     personFK = 5
     shiftPerson = models.ShiftPerson(shiftFK, personFK)
     result = shiftperson_controller._insertShiftPerson(shiftPerson, self.db)
     self.assertTrue(result > 0)
     
     newShiftPerson = models.ShiftPerson.query.filter_by(pk=result).first()
     self.assertEqual(newShiftPerson.pk, result)
     self.assertEqual(newShiftPerson.shiftFK, shiftFK)
     self.assertEqual(newShiftPerson.personFK, personFK)
 def test__insertShiftPerson_badperson(self):
     shiftFK = 1
     personFK = 999
     shiftPerson = models.ShiftPerson(shiftFK, personFK)
     result = shiftperson_controller._insertShiftPerson(shiftPerson, self.db)
     self.assertEqual(result, 'BadPerson')
 def test__insertShiftPerson_duplicate(self):
     shiftFK = 1
     personFK = 4
     shiftPerson = models.ShiftPerson(shiftFK, personFK)
     result = shiftperson_controller._insertShiftPerson(shiftPerson, self.db)
     self.assertEqual(result, 'Duplicate')