def test_flagging_a_position_adds_it_to_the_flagmap_or_removes_it_if_its_already_inside( self): board = Board(beginner, [1, 2, 3]) self.assertCountEqual([], board.flagmap) board = board.toggle_flag(1) self.assertCountEqual([1], board.flagmap) board = board.toggle_flag(4) self.assertCountEqual([1, 4], board.flagmap) board = board.toggle_flag(1) self.assertCountEqual([4], board.flagmap)
def test_opening_a_flagged_position_removes_the_flag_from_the_position( self): board = Board(beginner, [1, 2, 3], []) board = board.toggle_flag(20) self.assertCountEqual([20], board.flagmap) board = board.open(20) self.assertCountEqual([], board.flagmap)
def test_flagging_an_open_position_raises(self): board = Board(beginner, [1, 2, 3], [4]) with self.assertRaises(AlreadyRevealedException): board.toggle_flag(4)
def test_flagging_an_invalid_position_raises(self): board = Board(beginner, [1, 2, 3]) with self.assertRaises(InvalidPositionException): board.toggle_flag(-1)