Exemplo n.º 1
0
class TestReindeer(object):
    def setup(self):
        self.name = "Comet"
        self.params = Parameters(14, 10, 127)
        self.reindeer = Reindeer(self.name, *self.params)

    def test_init(self):
        assert self.reindeer.name == self.name
        assert self.reindeer.d_fly == self.params.d_fly
        assert self.reindeer.t_fly == self.params.t_fly
        assert self.reindeer.t_rest == self.params.t_rest
        assert self.reindeer.points == 0
        assert self.reindeer.time == 0
        assert self.reindeer.position == 0
        assert self.reindeer.state == "flying"
        assert self.reindeer.state_change_time == self.params.t_fly

    def test_step_once(self):
        self.reindeer.step()
        assert self.reindeer.time == 1
        assert self.reindeer.position == self.params.d_fly
        assert self.reindeer.state == "flying"
        assert self.reindeer.state_change_time == self.params.t_fly

    def test_step_until_state_change(self):
        self.reindeer.step(self.params.t_fly)
        assert self.reindeer.time == self.params.t_fly
        assert self.reindeer.position == self.params.t_fly * self.params.d_fly
        assert self.reindeer.state == "resting"
        assert self.reindeer.state_change_time == (self.params.t_fly +
                                                   self.params.t_rest)

    def test_step_until_next_state_change(self):
        self.reindeer.step(self.params.t_fly + self.params.t_rest)
        assert self.reindeer.time == self.params.t_fly + self.params.t_rest
        assert self.reindeer.position == self.params.t_fly * self.params.d_fly
        assert self.reindeer.state == "flying"
        assert self.reindeer.state_change_time == (2*self.params.t_fly +
                                                   self.params.t_rest)
Exemplo n.º 2
0
 def setup(self):
     self.name = "Comet"
     self.params = Parameters(14, 10, 127)
     self.reindeer = Reindeer(self.name, *self.params)