Ejemplo n.º 1
0
 def setup(self):
     """Pre-test setup"""
     self.track = ConditionTrack()
Ejemplo n.º 2
0
class TestConditionTrack:
    """Unit test suite for the ConditionTrack class."""

    def __init__(self):
        self.track = None

    def setup(self):
        """Pre-test setup"""
        self.track = ConditionTrack()

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

    def test_initial_position(self):
        """Verify the default track position is at the start."""
        assert self.track.get_position() == 0

    def test_initial_position_status(self):
        """Verify the default track position has no penalty."""
        assert self.track.get_condition() == 0

    def test_cannot_go_above_top(self):
        """Verify the upper bounds."""
        self.track.track_move(1)
        assert self.track.get_position() == 0
        assert self.track.get_condition() == 0

    def test_movement_down(self):
        """Verify normal track movement."""
        self.track.track_move(-1)
        assert self.track.get_position() == 1
        assert self.track.get_condition() == -1

        self.track.track_move(-2)
        assert self.track.get_position() == 3
        assert self.track.get_condition() == -5

    def test_cannot_go_below_bottom(self):
        """Verify the lower bounds"""
        self.track.track_move(-10)
        assert self.track.get_position() == 5
        assert self.track.get_condition() == 'helpless'

    def test_invalid_movement_input(self):
        """Verify invalid data throws an error."""
        try:
            self.track.track_move('test')
            assert False
        except TypeError:
            assert True