From 3d76181d2662ada213120598982296cab1eedd27 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 31 Oct 2022 09:25:38 +0100 Subject: [PATCH] Fix tests --- src/character/models/character.py | 4 ++-- src/character/tests/test_character.py | 30 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/character/models/character.py b/src/character/models/character.py index bd27927..de95af0 100644 --- a/src/character/models/character.py +++ b/src/character/models/character.py @@ -257,9 +257,9 @@ class Character(models.Model): if mana_max_compute == Profile.ManaMax.NO_MANA: return 0 elif mana_max_compute == Profile.ManaMax.LEVEL: - return self.level + self.modifier_intelligence + return self.level + self.modifier_magic else: - return 2 * self.level + self.modifier_intelligence + return 2 * self.level + self.modifier_magic @property def height_m(self) -> float: diff --git a/src/character/tests/test_character.py b/src/character/tests/test_character.py index 0ce5637..8498f23 100644 --- a/src/character/tests/test_character.py +++ b/src/character/tests/test_character.py @@ -2,7 +2,8 @@ import pytest from hypothesis import given from hypothesis.strategies import integers -from character.models.character import Character +from character.models.character import Character, Profile +from character.models.dice import Dice from character.tests.utils import ability_values, levels, modifier_test @@ -70,17 +71,24 @@ def test_defense(armor, shield, dexterity, misc): @given(level=levels(), intelligence=ability_values()) -def test_mana_max(level, intelligence): - char = Character(level=level, value_intelligence=intelligence) +def test_mana_max_mage(level, intelligence): + profile = Profile( + name="Magicien", + life_dice=Dice.D4, + magical_strength=Profile.MagicalStrength.INTELLIGENCE, + mana_max_compute=Profile.ManaMax.DOUBLE_LEVEL, + ) + char = Character(level=level, profile=profile, value_intelligence=intelligence) assert char.mana_max == 2 * level + modifier_test(intelligence) -@given( - level=levels(), intelligence=ability_values(), mana_consumed=integers(min_value=0) -) -def test_mana_remaining(level, intelligence, mana_consumed): - char = Character( - level=level, value_intelligence=intelligence, mana_consumed=mana_consumed +@given(level=levels(), wisdom=ability_values()) +def test_mana_max_druid(level, wisdom): + profile = Profile( + name="Druide", + life_dice=Dice.D4, + magical_strength=Profile.MagicalStrength.WISDOM, + mana_max_compute=Profile.ManaMax.LEVEL, ) - mana_max = 2 * level + modifier_test(intelligence) - assert char.mana_remaining == mana_max - mana_consumed + char = Character(level=level, profile=profile, value_wisdom=wisdom) + assert char.mana_max == level + modifier_test(wisdom)