def test_draw_strike_pins(): g = Game() RollService.roll(g, 10) dc = Mock() d = DrawService(dc) d.draw(g) assert dc.draw_strike.call_args_list[0] == call()
def test_draw_pins(): g = Game() for i in range(5): RollService.roll(g, i) dc = Mock() d = DrawService(dc) d.draw(g) assert dc.draw_pins.call_count == 5
def test_draw_spare_pins(): g = Game() RollService.roll(g, 2) RollService.roll(g, 8) dc = Mock() d = DrawService(dc) d.draw(g) assert dc.draw_pins.call_args_list[0] == call(2) assert dc.draw_spare.call_count == 1
def test_save(): stream = Mock() g = Game() RollService.roll(g, 3) SaveService(stream).save(g) assert stream.write_header.call_count == 5 assert stream.write_footer.call_count == 5 assert stream.write_count.call_args == call(1) assert stream.write_body.call_args == call(3)
def test_draw_score(): g = Game() for i in range(5): RollService.roll(g, i) dc = Mock() d = DrawService(dc) d.draw(g) assert dc.draw_score.call_count == 3 assert dc.draw_score.call_args_list[0] == call(1) assert dc.draw_score.call_args_list[1] == call(6) assert dc.draw_score.call_args_list[2] == call(10)
def do_roll(self, pins): RollService.roll(self.game, int(pins)) self.draw_game()