Skip to content

Commit

Permalink
test(backend): Add missing unit tests for the Parameter model
Browse files Browse the repository at this point in the history
  • Loading branch information
barnslig committed Jan 19, 2022
1 parent 2bbb028 commit 33eb002
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions backend/dpt_app/trails/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,27 @@ def test_update_clock_last_change(self):
self.assertEqual(self.game.clock_state, ClockType.STOPPED)
self.assertEqual(self.game.clock_last_change, now)
self.assertEqual(self.game.clock_duration, CLOCK_DURATION + 10)


class ParameterModelTest(GameTestCase):
def test_value_at(self):
# it returns the parameter value at the requested game duration
self.assertEqual(self.param.value_at(
0), self.param.initial_value + self.param.value)

# it does not go below the minimum parameter value
self.assertEqual(self.param.value_at(99999999), self.param.min_value)

# it does not go above the maximum parameter value
self.assertEqual(self.param.value_at(-99999999), self.param.max_value)

def test_current_value(self):
# it returns the current parameter value
self.assertEqual(self.param.current_value, 30)

def test_game_clock_duration_when_value_zero(self):
# it calculates the duration at which the parameter value first gets zero
duration_when_zero = self.param.game_clock_duration_when_value_zero

self.assertEqual(duration_when_zero, 100)
self.assertEqual(self.param.value_at(duration_when_zero), 0)

0 comments on commit 33eb002

Please sign in to comment.