Пример #1
0
 def test_elapsed_time_correct(self):
     now = datetime.utcnow()
     tenSecondsAgo = now - timedelta(seconds=10)
     # LegacyTimer must be running or elapsed time will be zero
     timer = LegacyTimer(startTime = tenSecondsAgo, running=True)
     timer.set_seconds_today(20)
     elapsed = timer.current_elapsed()
     total = timer.total_elapsed()
     assert(elapsed == 10)
     assert(total == 30)
 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
Пример #3
0
 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 test_elapsed_time_correct(self):
     now = datetime.utcnow()
     tenSecondsAgo = now - timedelta(seconds=10)
     # LegacyTimer must be running or elapsed time will be zero
     timer = LegacyTimer(startTime=tenSecondsAgo, running=True)
     timer.set_seconds_today(20)
     elapsed = timer.current_elapsed()
     total = timer.total_elapsed()
     assert (elapsed == 10)
     assert (total == 30)
 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_to_api_dict_correct(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"))
     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)
Пример #7
0
 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")
Пример #8
0
 def test_to_api_dict_correct(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"))
     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_create_with_explicit_start(self):
     my_notes = "I am another timer"
     timer = LegacyTimer(notes=my_notes,
                         startTime=datetime(2007, 12, 5, 0, 0))
     assert (my_notes == timer.notes)
     assert (timer.startTime == timer.lastRestart)
 def test_can_start_and_stop(self):
     notes = "Testing start and stop"
     t = LegacyTimer(notes=notes)
     t.start()
     t.stop()
 def test_can_create_with_utc_now(self):
     #userId = "561dcd3c8c57cf2c17b7f4f9"
     my_notes = "I want to know how long this took, but my code is brain dead so far.  Woe is me."
     timer = LegacyTimer(notes=my_notes)
     assert (my_notes == timer.notes)
     timer.save()
Пример #12
0
 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)
Пример #13
0
 def test_can_start_and_stop(self):
     notes = "Testing start and stop"
     t = LegacyTimer(notes=notes)
     t.start()
     t.stop()
Пример #14
0
 def test_can_create_with_utc_now(self):
     #userId = "561dcd3c8c57cf2c17b7f4f9"
     my_notes = "I want to know how long this took, but my code is brain dead so far.  Woe is me."
     timer = LegacyTimer(notes=my_notes)
     assert(my_notes == timer.notes)
     timer.save()
Пример #15
0
 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)