46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import unittest
|
|
|
|
from math_problems_structure.grade_1 import join_pictures_with_quantity
|
|
|
|
|
|
class JoinPicturesWithQuantityTest(unittest.TestCase):
|
|
def test_creates_problem(self) -> None:
|
|
problem = join_pictures_with_quantity(
|
|
available_pictures=[
|
|
{
|
|
"id": f"picture-{index}",
|
|
"name": f"Picture {index}",
|
|
"image_path": f"/images/{index}.png",
|
|
}
|
|
for index in range(10)
|
|
],
|
|
seed=1,
|
|
)
|
|
|
|
self.assertEqual(
|
|
problem["instructions"],
|
|
"Cuenta las imágenes y une cada grupo con el número correcto.",
|
|
)
|
|
self.assertEqual(len(problem["left_containers"]), 5)
|
|
self.assertEqual(len(problem["number_cards"]), 5)
|
|
self.assertEqual(len(problem["right_containers"]), 5)
|
|
|
|
def test_raises_for_too_few_pictures(self) -> None:
|
|
with self.assertRaisesRegex(
|
|
ValueError,
|
|
"available_pictures must contain at least 10 pictures",
|
|
):
|
|
join_pictures_with_quantity(
|
|
available_pictures=[
|
|
{
|
|
"id": "picture-1",
|
|
"name": "Picture 1",
|
|
"image_path": "/images/1.png",
|
|
}
|
|
]
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|