예제 #1
0
 def test_user_can_access_their_own_resource(self):
     test_objects = TestObjects()
     test_user = test_objects.get_test_user()
     timer = Timer(notes="More testing, boss", user=test_user)
     timer.save()
     assert(can_access_user_owned_resource(test_user, timer))
     timer.delete()
예제 #2
0
 def test_account_admin_cannot_access_resource_if_account_different(self):
     test_objects = TestObjects()
     test_user = test_objects.get_test_user()
     timer = Timer(notes="More testing, boss", user=test_user)
     timer.save()
     assert(can_access_user_owned_resource(test_user, timer))
     timer.delete()
예제 #3
0
 def test_can_save_and_load_timer(self):
     user = TestObjects().get_test_user()
     t = Timer(id=TestObjects().get_any_id(), notes="Saved from unit test", user=user)
     t.save()
     t2 = Timer.objects(id = t.id).first()
     assert(t.__repr__() == t2.__repr__())
     t.delete()
예제 #4
0
 def test_user_not_updated_on_save(self):
     user = TestObjects().get_test_user()
     t1 = Timer(id=ObjectId(b"Timer1Timer3"), notes="I want a shrubbery", user=user)
     t1.save()
     t1.user.password = "******"
     t1.save()
     # TODO ETC...
     t1.delete()
예제 #5
0
 def test_can_dump_and_load_timer(self):
     user = TestObjects().get_test_user()
     timer = Timer(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(Timer, 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())