Skip to content
5 changes: 4 additions & 1 deletion pyrit/converter/puzzled/puzzled_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import pathlib
import uuid
from typing import assert_never

from pyrit.common.path import CONVERTER_SEED_PROMPT_PATH
from pyrit.converter.converter import Converter, ConverterResult
Expand Down Expand Up @@ -197,8 +198,10 @@ async def convert_async(self, *, prompt: str, input_type: PromptDataType = "text
puzzle_body = build_word_search(words, rng)
elif puzzle_type is PuzzleType.ANAGRAM:
puzzle_body = build_anagram(words, rng)
else:
elif puzzle_type is PuzzleType.CROSSWORD:
puzzle_body = build_crossword(words)
else:
assert_never(puzzle_type)

semantics = await self._semantic_clues_async(words)
clues = "\n".join(self._clue_line(masked, semantics) for masked in mask_result.masked_words)
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/converter/test_puzzled_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ async def test_unsupported_input_type_raises():
await PuzzledConverter().convert_async(prompt=_PROMPT, input_type="image_path")


async def test_unhandled_puzzle_type_raises_async() -> None:
converter = PuzzledConverter(num_to_mask=2, seed=1)
with patch.object(converter, "_puzzle_type", "sudoku"):
with pytest.raises(AssertionError, match="Expected code to be unreachable, but got: 'sudoku'"):
await converter.convert_async(prompt=_PROMPT)


@pytest.mark.parametrize(
"puzzle_type, label",
[("word_search", "word search"), ("anagram", "anagram"), ("crossword", "crossword")],
Expand Down
Loading