1- from typing import List
1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+
4+ # pylint: disable=too-many-lines
25
6+ from typing import List
37import aiounittest
48from botbuilder .core import BotAdapter , TurnContext
59from botbuilder .core .teams import TeamsActivityHandler
@@ -116,12 +120,42 @@ async def on_teams_channel_deleted(
116120 channel_info , team_info , turn_context
117121 )
118122
123+ async def on_teams_team_archived (
124+ self , team_info : TeamInfo , turn_context : TurnContext
125+ ):
126+ self .record .append ("on_teams_team_archived" )
127+ return await super ().on_teams_team_archived (team_info , turn_context )
128+
129+ async def on_teams_team_deleted (
130+ self , team_info : TeamInfo , turn_context : TurnContext
131+ ):
132+ self .record .append ("on_teams_team_deleted" )
133+ return await super ().on_teams_team_deleted (team_info , turn_context )
134+
135+ async def on_teams_team_hard_deleted (
136+ self , team_info : TeamInfo , turn_context : TurnContext
137+ ):
138+ self .record .append ("on_teams_team_hard_deleted" )
139+ return await super ().on_teams_team_hard_deleted (team_info , turn_context )
140+
119141 async def on_teams_team_renamed_activity (
120142 self , team_info : TeamInfo , turn_context : TurnContext
121143 ):
122144 self .record .append ("on_teams_team_renamed_activity" )
123145 return await super ().on_teams_team_renamed_activity (team_info , turn_context )
124146
147+ async def on_teams_team_restored (
148+ self , team_info : TeamInfo , turn_context : TurnContext
149+ ):
150+ self .record .append ("on_teams_team_restored" )
151+ return await super ().on_teams_team_restored (team_info , turn_context )
152+
153+ async def on_teams_team_unarchived (
154+ self , team_info : TeamInfo , turn_context : TurnContext
155+ ):
156+ self .record .append ("on_teams_team_unarchived" )
157+ return await super ().on_teams_team_unarchived (team_info , turn_context )
158+
125159 async def on_invoke_activity (self , turn_context : TurnContext ):
126160 self .record .append ("on_invoke_activity" )
127161 return await super ().on_invoke_activity (turn_context )
@@ -365,6 +399,72 @@ async def test_on_teams_channel_deleted_activity(self):
365399 assert bot .record [0 ] == "on_conversation_update_activity"
366400 assert bot .record [1 ] == "on_teams_channel_deleted"
367401
402+ async def test_on_teams_team_archived (self ):
403+ # arrange
404+ activity = Activity (
405+ type = ActivityTypes .conversation_update ,
406+ channel_data = {
407+ "eventType" : "teamArchived" ,
408+ "team" : {"id" : "team_id_1" , "name" : "archived_team_name" },
409+ },
410+ channel_id = Channels .ms_teams ,
411+ )
412+
413+ turn_context = TurnContext (NotImplementedAdapter (), activity )
414+
415+ # Act
416+ bot = TestingTeamsActivityHandler ()
417+ await bot .on_turn (turn_context )
418+
419+ # Assert
420+ assert len (bot .record ) == 2
421+ assert bot .record [0 ] == "on_conversation_update_activity"
422+ assert bot .record [1 ] == "on_teams_team_archived"
423+
424+ async def test_on_teams_team_deleted (self ):
425+ # arrange
426+ activity = Activity (
427+ type = ActivityTypes .conversation_update ,
428+ channel_data = {
429+ "eventType" : "teamDeleted" ,
430+ "team" : {"id" : "team_id_1" , "name" : "deleted_team_name" },
431+ },
432+ channel_id = Channels .ms_teams ,
433+ )
434+
435+ turn_context = TurnContext (NotImplementedAdapter (), activity )
436+
437+ # Act
438+ bot = TestingTeamsActivityHandler ()
439+ await bot .on_turn (turn_context )
440+
441+ # Assert
442+ assert len (bot .record ) == 2
443+ assert bot .record [0 ] == "on_conversation_update_activity"
444+ assert bot .record [1 ] == "on_teams_team_deleted"
445+
446+ async def test_on_teams_team_hard_deleted (self ):
447+ # arrange
448+ activity = Activity (
449+ type = ActivityTypes .conversation_update ,
450+ channel_data = {
451+ "eventType" : "teamHardDeleted" ,
452+ "team" : {"id" : "team_id_1" , "name" : "hard_deleted_team_name" },
453+ },
454+ channel_id = Channels .ms_teams ,
455+ )
456+
457+ turn_context = TurnContext (NotImplementedAdapter (), activity )
458+
459+ # Act
460+ bot = TestingTeamsActivityHandler ()
461+ await bot .on_turn (turn_context )
462+
463+ # Assert
464+ assert len (bot .record ) == 2
465+ assert bot .record [0 ] == "on_conversation_update_activity"
466+ assert bot .record [1 ] == "on_teams_team_hard_deleted"
467+
368468 async def test_on_teams_team_renamed_activity (self ):
369469 # arrange
370470 activity = Activity (
@@ -387,6 +487,50 @@ async def test_on_teams_team_renamed_activity(self):
387487 assert bot .record [0 ] == "on_conversation_update_activity"
388488 assert bot .record [1 ] == "on_teams_team_renamed_activity"
389489
490+ async def test_on_teams_team_restored (self ):
491+ # arrange
492+ activity = Activity (
493+ type = ActivityTypes .conversation_update ,
494+ channel_data = {
495+ "eventType" : "teamRestored" ,
496+ "team" : {"id" : "team_id_1" , "name" : "restored_team_name" },
497+ },
498+ channel_id = Channels .ms_teams ,
499+ )
500+
501+ turn_context = TurnContext (NotImplementedAdapter (), activity )
502+
503+ # Act
504+ bot = TestingTeamsActivityHandler ()
505+ await bot .on_turn (turn_context )
506+
507+ # Assert
508+ assert len (bot .record ) == 2
509+ assert bot .record [0 ] == "on_conversation_update_activity"
510+ assert bot .record [1 ] == "on_teams_team_restored"
511+
512+ async def test_on_teams_team_unarchived (self ):
513+ # arrange
514+ activity = Activity (
515+ type = ActivityTypes .conversation_update ,
516+ channel_data = {
517+ "eventType" : "teamUnarchived" ,
518+ "team" : {"id" : "team_id_1" , "name" : "unarchived_team_name" },
519+ },
520+ channel_id = Channels .ms_teams ,
521+ )
522+
523+ turn_context = TurnContext (NotImplementedAdapter (), activity )
524+
525+ # Act
526+ bot = TestingTeamsActivityHandler ()
527+ await bot .on_turn (turn_context )
528+
529+ # Assert
530+ assert len (bot .record ) == 2
531+ assert bot .record [0 ] == "on_conversation_update_activity"
532+ assert bot .record [1 ] == "on_teams_team_unarchived"
533+
390534 async def test_on_teams_members_added_activity (self ):
391535 # arrange
392536 activity = Activity (
0 commit comments