def test_getShiftByEventJSON_false(self):
     key = 999
     shiftListJSON = shifts_controller.getShiftsByEventJSON(key)
     shiftListDict = json.loads(shiftListJSON)
     for rootKey, rootVal in shiftListDict.iteritems():
         self.assertEqual(rootKey, 'Shifts')
         self.assertEqual(rootVal, 'None')
Пример #2
0
def getShiftsByEvent(org_id, event_id):
    try:
        shiftListJSON = shifts_controller.getShiftsByEventJSON(event_id)
        shiftListDict = json.loads(shiftListJSON)
        if is_request_json():
            return jsonify(shiftListDict, event_id=event_id)

    except Exception, e:
        return abort(404)
 def test_getShiftByEventJSON_true(self):
     key = 1
     shiftListJSON = shifts_controller.getShiftsByEventJSON(key)
     shiftListDict = json.loads(shiftListJSON)
     for rootKey, rootVal in shiftListDict.iteritems():
         self.assertEqual(rootKey, 'Shifts')
         counter = 0
         for shiftJSON in rootVal:
             shift = shifts_controller.extractShiftFromDict(shiftJSON)
             self.assertEqual(shift.eventFK, key)
             self.assertEqual(shift.location, 'Booth A')
             if shift.pk == 1:
                 counter += 1
                 self.assertEqual(shift.startdatetime, datetime.datetime(2013, 7, 12, 12, 0))
                 self.assertEqual(shift.enddatetime, datetime.datetime(2013, 7, 12, 13, 0))
                 self.assertEqual(shift.minWorkers, 2)
                 self.assertEqual(shift.maxWorkers, 4)
             elif shift.pk == 2:
                 counter += 1
                 self.assertEqual(shift.startdatetime, datetime.datetime(2013, 7, 12, 13, 0))
                 self.assertEqual(shift.enddatetime, datetime.datetime(2013, 7, 12, 14, 0))
                 self.assertEqual(shift.minWorkers, 2)
                 self.assertEqual(shift.maxWorkers, 4)
             elif shift.pk == 3:
                 counter += 1
                 self.assertEqual(shift.startdatetime, datetime.datetime(2013, 7, 12, 14, 0))
                 self.assertEqual(shift.enddatetime, datetime.datetime(2013, 7, 12, 15, 0))
                 self.assertEqual(shift.minWorkers, 3)
                 self.assertEqual(shift.maxWorkers, 4)
             elif shift.pk == 4:
                 counter += 1
                 self.assertEqual(shift.startdatetime, datetime.datetime(2013, 7, 12, 15, 0))
                 self.assertEqual(shift.enddatetime, datetime.datetime(2013, 7, 12, 16, 0))
                 self.assertEqual(shift.minWorkers, 3)
                 self.assertEqual(shift.maxWorkers, 4)
         self.assertEqual(counter, 4)