Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmittag authored and SebastianSchildt committed Nov 20, 2023
1 parent be567ae commit c507dc3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 7 additions & 1 deletion mock_service/lib/animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
self._done = False
self._repeat_mode = repeat_mode
self._value_update_callback = value_update_callback
self._value = self._values[0]

def tick(self, delta_time: float):
if self._done:
Expand All @@ -86,12 +87,17 @@ def tick(self, delta_time: float):
elif self._repeat_mode == RepeatMode.REPEAT:
self._anim_time = self._anim_time - self._duration

self._value = self._interpolation(self._anim_time)

if self._value_update_callback is not None:
self._value_update_callback(self._interpolation(self._anim_time))
self._value_update_callback(self._value)

def is_done(self) -> bool:
return self._done

def get_value(self):
return self._value

def __eq__(self, other) -> bool:
return (
isinstance(other, ValueAnimator)
Expand Down
16 changes: 8 additions & 8 deletions mock_service/test/test_animator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

def test_value_animator_no_repeat():
anim = ValueAnimator([0.0, 10.0], 10.0, RepeatMode.ONCE)
v0 = anim.value()
v0 = anim.get_value()
anim.tick(5.0)
v1 = anim.value()
v1 = anim.get_value()
anim.tick(5.0)
v2 = anim.value()
v2 = anim.get_value()
anim.tick(5.0)
v3 = anim.value()
v3 = anim.get_value()

assert v0 == 0.0
assert v1 == 5.0
Expand All @@ -33,13 +33,13 @@ def test_value_animator_no_repeat():

def test_value_animator_repeat():
anim = ValueAnimator([0.0, 100.0], 10.0, RepeatMode.REPEAT)
v0 = anim.value()
v0 = anim.get_value()
anim.tick(5.0)
v1 = anim.value()
v1 = anim.get_value()
anim.tick(5.0)
v2 = anim.value()
v2 = anim.get_value()
anim.tick(2.0)
v3 = anim.value()
v3 = anim.get_value()

assert v0 == 0.0
assert v1 == 50.0
Expand Down

0 comments on commit c507dc3

Please sign in to comment.