Spaces:
Sleeping
Sleeping
add unit tests
Browse files- tests/unit/test_cube.py +29 -0
tests/unit/test_cube.py
CHANGED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
|
3 |
+
|
4 |
+
from rubik.cube import Cube
|
5 |
+
|
6 |
+
|
7 |
+
class TestCube:
|
8 |
+
"""
|
9 |
+
A testing class for the Cube class.
|
10 |
+
"""
|
11 |
+
|
12 |
+
@pytest.mark.parametrize(
|
13 |
+
"colors, size",
|
14 |
+
[
|
15 |
+
[["U", "L", "C", "R", "B", "D"], 3],
|
16 |
+
[["Up", "Left", "Center", "Right", "Back", "Down"], 5],
|
17 |
+
[["A", "BB", "CCC", "DDDD", "EEEEE", "FFFFFF"], 10],
|
18 |
+
],
|
19 |
+
)
|
20 |
+
def test__init__(self, colors: list[str], size: int):
|
21 |
+
"""
|
22 |
+
Test that the __init__ method produce expected attributes.
|
23 |
+
"""
|
24 |
+
cube = Cube(colors, size)
|
25 |
+
assert cube.coordinates.shape == (6 * (size**2), 4), (
|
26 |
+
f"'coordinates' has incorrect shape {cube.coordinates.shape}"
|
27 |
+
)
|
28 |
+
assert cube.state.shape == (6 * (size**2), 7), f"'state' has incorrect shape {cube.state.shape}"
|
29 |
+
assert len(cube.history) == 0, "'history' field should be empty"
|