generate crosswords using crossword algorithm
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import pytest
|
||||
from multiplayer_crosswords.crossword import Crossword, Orientation, PlacedWord
|
||||
from unittest.mock import MagicMock
|
||||
from multiplayer_crosswords.dictionary import Dictionary
|
||||
from multiplayer_crosswords.utils import load_en_dictionary, load_de_dictionary
|
||||
|
||||
class DummyWord:
|
||||
def __init__(self, word):
|
||||
@ -96,4 +98,18 @@ def test_valid_hello_world_crossword():
|
||||
assert str(cw).count('O') == 1
|
||||
assert str(cw).count('W') == 1
|
||||
assert str(cw).count('R') == 1
|
||||
assert str(cw).count('D') == 1
|
||||
assert str(cw).count('D') == 1
|
||||
|
||||
|
||||
def test_crossword_generation():
|
||||
dictionary = load_de_dictionary()
|
||||
crossword = Crossword.generate(15, 15, dictionary)
|
||||
assert crossword is not None
|
||||
|
||||
# Basic checks on the generated crossword
|
||||
assert len(crossword.grid) == 15
|
||||
assert all(len(row) == 15 for row in crossword.grid)
|
||||
assert len(crossword.placed_words) > 0
|
||||
|
||||
# print the crossword for visual inspection
|
||||
print(crossword)
|
||||
Reference in New Issue
Block a user