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__insertShift_true(self): shift = models.Shift() eventFK = 1 start = datetime.datetime(2013, 7, 24, 13, 0) end = datetime.datetime(2013, 7, 24, 14, 0) location = 'Booth B' minWorkers = 24 maxWorkers = 42 shift.eventFK = eventFK shift.startdatetime = start shift.enddatetime = end shift.location = location shift.minWorkers = minWorkers shift.maxWorkers = maxWorkers result = shifts_controller._insertShift(shift, self.db) self.assertTrue(result > 0) newShift = models.Shift.query.filter_by(pk=result).first() self.assertEqual(newShift.pk, result) self.assertEqual(newShift.eventFK, eventFK) self.assertEqual(newShift.startdatetime, start) self.assertEqual(newShift.enddatetime, end) self.assertEqual(newShift.location, location) self.assertEqual(newShift.minWorkers, minWorkers) self.assertEqual(newShift.maxWorkers, maxWorkers)
def test__insertShift_badevent(self): shift = models.Shift() eventFK = 0 start = datetime.datetime(2013, 7, 12, 15, 0) end = datetime.datetime(2013, 7, 12, 16, 0) location = 'Booth A' minWorkers = 3 maxWorkers = 4 shift.eventFK = eventFK shift.startdatetime = start shift.enddatetime = end shift.location = location shift.minWorkers = minWorkers shift.maxWorkers = maxWorkers result = shifts_controller._insertShift(shift, self.db) self.assertEqual(result, 'BadEvent')