1- # test_basic.py
2- # A very small test just to confirm the core logic works.
3- # Full testing is beyond the scope of this assignment, but this shows
4- # that the sadness function behaves correctly for a simple case.
1+
52#If a person gets a laptop with their first‑choice operating system, their sadness should be 0.
63from laptop import Person , Laptop , OperatingSystem , sadness
74
@@ -10,3 +7,25 @@ def test_sadness_first_choice():
107 laptop = Laptop (1 , "Apple" , "macBook" , 13 , OperatingSystem .MACOS )
118
129 assert sadness (person , laptop ) == 0
10+ from laptop import Person , Laptop , OperatingSystem , sadness , TERRIBLE_SADNESS
11+ #Adding more tests
12+ def test_sadness_second_choice ():
13+ person = Person ("Test" , 20 , (OperatingSystem .MACOS , OperatingSystem .UBUNTU ))
14+ laptop = Laptop (1 , "Dell" , "XPS" , 13 , OperatingSystem .UBUNTU )
15+ assert sadness (person , laptop ) == 1
16+
17+
18+ def test_sadness_not_in_preferences ():
19+ person = Person ("Test" , 20 , (OperatingSystem .MACOS ,))
20+ laptop = Laptop (1 , "Dell" , "XPS" , 13 , OperatingSystem .UBUNTU )
21+ assert sadness (person , laptop ) == TERRIBLE_SADNESS
22+
23+
24+ def test_sadness_above_max_rank ():
25+ # as our MAX_HAPPY_RANK = 3, so rank 3 should be TERRIBLE_SADNESS
26+ person = Person (
27+ "Test" , 20 ,
28+ (OperatingSystem .MACOS , OperatingSystem .UBUNTU , OperatingSystem .ARCH )
29+ )
30+ laptop = Laptop (1 , "Dell" , "XPS" , 13 , OperatingSystem .ARCH )
31+ assert sadness (person , laptop ) == TERRIBLE_SADNESS
0 commit comments