def test_to_api_dict_correct(self): start_time = dateutil.parser.parse('2008-09-03T20:00:00.000000Z') # Timer must be running or elapsed time will be zero timer = Timer(startTime = start_time, running=True, id=ObjectId("56259a278c57cf02f9692b31")) d = timer.to_api_dict() json = dumps(d) assert('"notes": null' in json) assert('"id": "56259a278c57cf02f9692b31"' in json) assert('"entries": []' in json) #assert('"seconds": 20' in json) timer.notes = "Testing the JSON!" timer.set_seconds_today(99) d = timer.to_api_dict() json = dumps(d) assert('"notes": "Testing the JSON!"' in json) assert('"seconds": 99' in json)
def test_can_load_from_api_dict(self): start_time = dateutil.parser.parse('2008-09-03T20:00:00.000000Z') # Timer must be running or elapsed time will be zero timer = Timer(startTime = start_time, running=True, id=ObjectId("56259a278c57cf02f9692b31")) timer.set_seconds_today(99) d = timer.to_api_dict() t2 = Timer.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 = Timer.load_from_dict(d) assert(t2.notes == "Testing")