11import unittest
2- from activities import eat , nap
2+ from activities import eat , nap , is_funny , laugh
33
44class ActivityTest (unittest .TestCase ):
55 def test_eat_healthy (self ):
@@ -8,24 +8,45 @@ def test_eat_healthy(self):
88 eat ("broccoli" , is_healthy = True ),
99 "I'm eating broccoli, because my body is a temple"
1010 )
11+
1112 def test_eat_unhealthy (self ):
1213 """eat should indicate you've given up for unhealthy eating"""
1314 self .assertEqual (
1415 eat ("pizza" , is_healthy = False ),
1516 "I'm eating pizza, because YOLO"
1617 )
18+
19+ def test_eat_healthy_boolean (self ):
20+ """is_healthy must be a boolean"""
21+ with self .assertRaises (ValueError ):
22+ eat ("pizza" , is_healthy = "who cares?" )
23+
1724 def test_short_nap (self ):
1825 """short naps should be refreshing"""
1926 self .assertEqual (
2027 nap (1 ),
2128 "I'm feeling refreshed after my 1 hour nap"
2229 )
30+
2331 def test_long_nap (self ):
2432 """long naps should be discouraging"""
2533 self .assertEqual (
2634 nap (3 ),
2735 "Ugh, I overslept. I didn't mean to nap for 3 hours"
2836 )
2937
38+ def test_is_funny_tim (self ):
39+ """Tim should not be funny"""
40+ self .assertFalse (is_funny ("tim" ), "Tim should not be funny" )
41+
42+ def test_is_funny_anyone_else (self ):
43+ """anyone else but Tim should be funny"""
44+ self .assertTrue (is_funny ("blue" ), "Blue should be funny" )
45+ self .assertTrue (is_funny ("tammy" ), "Tammy should be funny" )
46+ self .assertTrue (is_funny ("sven" ), "Sven should be funny" )
47+
48+ def test_laugh (self ):
49+ self .assertIn (laugh (), ("lol" , "haha" , "tehehe" ))
50+
3051if __name__ == "__main__" :
3152 unittest .main ()
0 commit comments