@@ -146,7 +146,7 @@ def testSource(self):
146
146
147
147
def testBudord (self ):
148
148
"""Test that marvin knows all the commandments"""
149
- for n in range (1 , 5 ):
149
+ for n in range (1 , 6 ):
150
150
self .assertStringsOutput (marvin_actions .marvinBudord , f"budord #{ n } " , "budord" , f"#{ n } " )
151
151
152
152
self .assertStringsOutput (marvin_actions .marvinBudord ,"visa stentavla 1" , "budord" , "#1" )
@@ -261,6 +261,15 @@ def testNameDayResponse(self):
261
261
self .assertNameDayOutput ("double" , "Idag har Alfred,Alfrida namnsdag" )
262
262
self .assertNameDayOutput ("nobody" , "Ingen har namnsdag idag" )
263
263
264
+ def testNameDayError (self ):
265
+ """Tests that marvin returns the proper error message when nameday API is down"""
266
+ with mock .patch ("marvin_actions.requests.get" , side_effect = Exception ("API Down!" )):
267
+ self .assertStringsOutput (
268
+ marvin_actions .marvinNameday ,
269
+ "har någon namnsdag idag?" ,
270
+ "nameday" ,
271
+ "error" )
272
+
264
273
def testJokeRequest (self ):
265
274
"""Test that marvin sends a proper request for a joke"""
266
275
with mock .patch ("marvin_actions.requests" ) as r :
@@ -324,6 +333,15 @@ def testCommitResponse(self):
324
333
expected = f"Använd detta meddelandet: '{ message } '"
325
334
self .assertActionOutput (marvin_actions .marvinCommit , "commit" , expected )
326
335
336
+ def testCommitError (self ):
337
+ """Tests that marvin sends the proper message when get commit fails"""
338
+ with mock .patch ("marvin_actions.requests.get" , side_effect = Exception ('API Down!' )):
339
+ self .assertStringsOutput (
340
+ marvin_actions .marvinCommit ,
341
+ "vad skriver man efter commit -m?" ,
342
+ "commit" ,
343
+ "error" )
344
+
327
345
def testMorning (self ):
328
346
"""Test that marvin wishes good morning, at most once per day"""
329
347
marvin_general_actions .lastDateGreeted = None
0 commit comments