99from ..exercises .exercise_75 import BankCustomer
1010from ..exercises .exercise_76 import Box
1111from ..exercises .exercise_77 import create_content , Blogger , Vlogger
12-
13- # from ..exercises.exercise_78 import
12+ from ..exercises .exercise_78 import Course , Student , Professor
1413
1514
1615def test_e68 ():
@@ -118,8 +117,9 @@ def test_e74():
118117 customer = Customer ("John" , "Doe" )
119118 card = Card (
120119 card_number = "1234" ,
121- customer = customer ,
122- expiry_date = "2024-12-31" ,
120+ card_holder = "John Doe" ,
121+ account_number = "1234" ,
122+ expiration_date = "2024-12-31" ,
123123 pin = "1234" ,
124124 )
125125 assert isinstance (card , Card )
@@ -130,10 +130,13 @@ def test_e74():
130130
131131def test_e75 ():
132132 customer = BankCustomer ("John" , "Doe" )
133- card1 = Card ("1234" , customer , "2024-12-31" , "1234" )
134- card2 = Card ("5678" , customer , "2024-12-31" , "5678" )
135- account1 = Account ("acc-1234" , customer , 1000 , [card1 ])
136- account2 = Account ("acc-5678" , customer , 2000 , [card2 ])
133+ account1 = Account ("acc-1234" , customer , 1000 )
134+ card1 = Card ("1234" , "John Doe" , "acc-1234" , "2024-12-31" , "1234" )
135+ account1 .add_card (card1 )
136+
137+ account2 = Account ("acc-5678" , customer , 2000 )
138+ card2 = Card ("5678" , "John Doe" , "acc-5678" , "2024-12-31" , "5678" )
139+ account2 .add_card (card2 )
137140
138141 assert customer .get_total_balance () == 0.0
139142 customer .add_account (account1 )
@@ -172,5 +175,44 @@ def test_e76():
172175
173176
174177def test_e77 ():
175- assert create_content (Blogger ()) == "Blogger is creating content"
176- assert create_content (Vlogger ()) == "Vlogger is creating content"
178+ assert create_content (Blogger (), "New Post" ) == "Creating a new post: New Post"
179+ assert (
180+ create_content (Vlogger (), "New Video" )
181+ == "Creating a new video: New Video with path: /videos/New Video.mp4"
182+ )
183+
184+ class NotAContentCreator :
185+ pass
186+
187+ with pytest .raises (AttributeError ):
188+ create_content (NotAContentCreator (), "New Content" )
189+
190+
191+ def test_e78 ():
192+ course = Course ("Python Programming" , "CS101" )
193+ assert course .course_name == "Python Programming"
194+ assert course .course_code == "CS101"
195+ assert course .professor is None
196+ assert course .students == []
197+
198+ professor = Professor ("Dr. Clark" , "clark@uni.edu" , "1234" )
199+ course .assign_professor (professor )
200+
201+ student_names = ["Alice" , "Bob" , "Charlie" ]
202+ students = [
203+ Student (name , f"{ name .lower ()} @uni.edu" , f"{ name .lower ()} 1234" )
204+ for name in student_names
205+ ]
206+ for student in students :
207+ student .enroll (course )
208+
209+ assert course .professor == professor
210+ assert set (course .list_students ()) == set (student_names )
211+
212+ course2 = Course ("Mathematics" , "MATH101" )
213+ assert course2 .professor is None
214+ assert course2 .students == []
215+ professor2 = Professor ("Dr. Smith" , "smith@uni.edu" , "5678" )
216+ course2 .assign_professor (professor2 )
217+ assert course2 .professor == professor2
218+ assert course2 .students == []
0 commit comments