def test_can_load_from_api_dict(self): start_time = dateutil.parser.parse('2008-09-03T20:00:00.000000Z') # LegacyTimer must be running or elapsed time will be zero timer = LegacyTimer(startTime = start_time, running=True, id=ObjectId("56259a278c57cf02f9692b31")) timer.set_seconds_today(99) d = timer.to_api_dict() t2 = LegacyTimer.load_from_dict(d) assert(timer.notes == t2.notes) assert(timer.id == t2.id) assert(timer.entries[0].dateRecorded == t2.entries[0].dateRecorded) assert(len(timer.entries) == len(t2.entries)) assert(timer.entries[0].seconds == t2.entries[0].seconds) d["notes"] = "Testing" t2 = LegacyTimer.load_from_dict(d) assert(t2.notes == "Testing")
def test_can_load_from_api_dict(self): start_time = dateutil.parser.parse('2008-09-03T20:00:00.000000Z') # LegacyTimer must be running or elapsed time will be zero timer = LegacyTimer(startTime=start_time, running=True, id=ObjectId("56259a278c57cf02f9692b31")) timer.set_seconds_today(99) d = timer.to_api_dict() t2 = LegacyTimer.load_from_dict(d) assert (timer.notes == t2.notes) assert (timer.id == t2.id) assert (timer.entries[0].dateRecorded == t2.entries[0].dateRecorded) assert (len(timer.entries) == len(t2.entries)) assert (timer.entries[0].seconds == t2.entries[0].seconds) d["notes"] = "Testing" t2 = LegacyTimer.load_from_dict(d) assert (t2.notes == "Testing")
def post(self): json = request.json timer = LegacyTimer.load_from_dict(json) timer.save() location = api_root + "/timer/" + str(timer.id) response = jsonify(timer.to_api_dict()) response.headers["location"] = location response.status_code = 201 return response
def put(self, timer_id): # To do review exceptions, also, does json ID match timer_id? # If not return bad request timer = LegacyTimer.load_from_dict(request.json) TimerDaoLegacy().save_timer(timer) return(None, 204)
def put(self, timer_id): # To do review exceptions, also, does json ID match timer_id? # If not return bad request timer = LegacyTimer.load_from_dict(request.json) TimerDaoLegacy().save_timer(timer) return (None, 204)