def test_can_save_and_load_timer(self):
     user = TestObjects().get_test_user()
     t = TimerEntity(id=TestObjects().get_any_id(), notes="Saved from unit test", user=user )
     t.save()
     t2 = TimerEntity.objects(id = t.id).first()
     assert(t.__repr__() == t2.__repr__())
     t.delete()
 def test_user_not_updated_on_save(self):
     user = TestObjects().get_test_user()
     t1 = TimerEntity(id=ObjectId(b"Timer1Timer3"), notes="I want a shrubbery", user=user)
     t1.save()
     t1.user.password = "******"
     t1.save()
     # TODO ETC...
     t1.delete()
 def test_can_save_and_load_timer(self):
     user = TestObjects().get_test_user()
     t = TimerEntity(id=TestObjects().get_any_id(),
                     notes="Saved from unit test",
                     user=user)
     t.save()
     t2 = TimerEntity.objects(id=t.id).first()
     assert (t.__repr__() == t2.__repr__())
     t.delete()
 def test_user_not_updated_on_save(self):
     user = TestObjects().get_test_user()
     t1 = TimerEntity(id=ObjectId(b"Timer1Timer3"),
                      notes="I want a shrubbery",
                      user=user)
     t1.save()
     t1.user.password = "******"
     t1.save()
     # TODO ETC...
     t1.delete()
 def test_can_dump_and_load_timer(self):
     user = TestObjects().get_test_user()
     timer = TimerEntity(notes="Just a test timer", user=user, tags=["Unit Tests"], seconds = 22, running = True)
     timer.save()
     tf = TimerFormatter()
     timer_entity_as_dict = tf.model_to_dict(timer)
     timer.delete()
     timer2 = tf.dict_to_model(TimerEntity, timer_entity_as_dict)
     # This won't pass, there are subtle, trivial differences in datetimes once dates have been serialized
     #assert(timer.lastRestart == timer2.lastRestart)
     #assert(timer.dateEntered == timer2.dateEntered)
     assert(timer.tags == timer2.tags)
     assert(timer.running == timer2.running)
     assert(timer.seconds == timer2.seconds)
     assert(timer.notes == timer2.notes)
     assert(timer.user == timer2.user)
     assert(timer.to_json() == timer2.to_json())
 def test_can_dump_and_load_timer(self):
     user = TestObjects().get_test_user()
     timer = TimerEntity(notes="Just a test timer",
                         user=user,
                         tags=["Unit Tests"],
                         seconds=22,
                         running=True)
     timer.save()
     tf = TimerFormatter()
     timer_entity_as_dict = tf.model_to_dict(timer)
     timer.delete()
     timer2 = tf.dict_to_model(TimerEntity, timer_entity_as_dict)
     # This won't pass, there are subtle, trivial differences in datetimes once dates have been serialized
     #assert(timer.lastRestart == timer2.lastRestart)
     #assert(timer.dateEntered == timer2.dateEntered)
     assert (timer.tags == timer2.tags)
     assert (timer.running == timer2.running)
     assert (timer.seconds == timer2.seconds)
     assert (timer.notes == timer2.notes)
     assert (timer.user == timer2.user)
     assert (timer.to_json() == timer2.to_json())