Exemplo n.º 1
0
 def setup(self):
     """Pre-test setup"""
     self.ability = Ability(None, 8)
Exemplo n.º 2
0
class TestAbility:
    """Unit tests for the Ability class."""

    def __init__(self):
        self.ability = None

    def setup(self):
        """Pre-test setup"""
        self.ability = Ability(None, 8)

    def teardown(self):
        """Post-test cleanup"""
        self.ability = None

    def test_can_decrement(self):
        self.ability.value = 10
        self.ability.decrement()
        assert self.ability.value == 9

    def test_min_score_is_eight(self):
        self.ability.decrement()
        assert self.ability.value == 8

    def test_can_increment(self):
        self.ability.increment()
        assert self.ability.value == 9

    def test_mod_changes_with_increment(self):
        assert self.ability.modifier == -1
        self.ability.increment()
        self.ability.increment()
        assert self.ability.modifier == 0

    def test_mod_changes_with_decrement(self):
        self.ability.value = 10
        assert self.ability.modifier == 0
        self.ability.decrement()
        assert self.ability.modifier == -1

    def test_get_points_spent(self):
        assert self.ability.cost == 0
        self.ability.increment()
        self.ability.increment()
        assert self.ability.cost == 2

    def test_cost_to_increase_score(self):
        assert self.ability.increase_cost == 1
        self.ability.value = 15
        assert self.ability.increase_cost == 2
        self.ability.value = 18
        assert self.ability.increase_cost == 0

    def test_cost_to_decrease_score(self):
        assert self.ability.decrease_cost == 0
        self.ability.value = 15
        assert self.ability.decrease_cost == 2
        self.ability.value = 18
        assert self.ability.decrease_cost == 3