1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+ """
4+ Created on Wed May 20 15:14:10 2026
5+
6+ @author: kasteivanauskaite
7+ """
8+ from knitting_pattern .math_engine import (
9+ calculate_stitches ,
10+ calculate_rows ,
11+ get_standard_body_measurements
12+ )
13+
14+ # ==========================================
15+ # 1. GAUGE CALCULATOR TESTS
16+ # ==========================================
17+ def test_calculate_stitches ():
18+ # If a fabric is 10cm wide, and gauge is 20 sts per 10cm, we expect 20 stitches.
19+ assert calculate_stitches (10.0 , 20.0 ) == 20
20+
21+ # If fabric is 15cm wide, and gauge is 22 sts per 10cm (2.2 sts/cm)
22+ # 15 * 2.2 = 33 stitches
23+ assert calculate_stitches (15.0 , 22.0 ) == 33
24+
25+ # Testing rounding: 10.5cm * 2.2 = 23.1. Should round up to 24.
26+ assert calculate_stitches (10.5 , 22.0 ) == 24
27+
28+ def test_calculate_rows ():
29+ # 10cm length at 30 rows/10cm should equal 30 rows
30+ assert calculate_rows (10.0 , 30.0 ) == 30
31+
32+ # ==========================================
33+ # 2. SIZING DATA TESTS
34+ # ==========================================
35+ def test_get_standard_body_measurements ():
36+ # Test that size Medium returns the correct dictionary
37+ m_size = get_standard_body_measurements ("M" )
38+ assert m_size ["chest_circ_cm" ] == 96.0
39+
40+ # Test that lowercase inputs are handled properly
41+ s_size = get_standard_body_measurements ("s" )
42+ assert s_size ["chest_circ_cm" ] == 86.0
43+
44+ # Test fallback: an invalid size should default to Medium (96.0)
45+ invalid_size = get_standard_body_measurements ("NONEXISTENT" )
46+ assert invalid_size ["chest_circ_cm" ] == 96.0
0 commit comments