def test_answet_target(self): base = SeaField(4, 4) SeaPlayground.handle_shoot_answer(base, SIGNALS.HITTING, [(0, 1)]) SeaPlayground.handle_shoot_answer(base, SIGNALS.MISS, [(1, 1)]) SeaPlayground.handle_shoot_answer(base, SIGNALS.MISS, [(2, 1)]) SeaPlayground.handle_shoot_answer(base, SIGNALS.KILLED, [(3, 1)]) for cell in base._cells: if cell.x in (1, 2, 3) and cell.y in (0, 2): assert cell.value == Cell.BORDER elif (cell.x, cell.y) in ((1, 1), (2, 1)): assert cell.value == Cell.MISSED elif (cell.x, cell.y) in ((0, 1), (3, 1)): assert cell.value == Cell.HIT else: assert cell.value == Cell.EMPTY
def test_answer_target_incorrect_cell(self): base = SeaField(4, 4) with self.assertRaises(IncorrectCoordinate): SeaPlayground.handle_shoot_answer(base, SIGNALS.HITTING, [(-1, 0)]) with self.assertRaises(IncorrectCoordinate): SeaPlayground.handle_shoot_answer(base, SIGNALS.HITTING, [(1, 11110)]) with self.assertRaises(IncorrectCoordinate): SeaPlayground.handle_shoot_answer(base, SIGNALS.HITTING, [(i, i) for i in range(10)])