@@ -52,6 +52,64 @@ def create_conversation():
5252 handler = TestTeamsActivityHandler ()
5353 await handler .on_turn (turn_context )
5454
55+ async def test_send_message_to_teams_channels_without_turn_context (self ):
56+ activity = Activity (
57+ type = "message" ,
58+ text = "test_send_message_to_teams_channel" ,
59+ channel_id = Channels .ms_teams ,
60+ service_url = "https://example.org" ,
61+ channel_data = TeamsChannelData (team = TeamInfo (id = "team-id" )),
62+ )
63+
64+ try :
65+ await TeamsInfo .send_message_to_teams_channel (None , activity , "channelId123" )
66+ except ValueError :
67+ pass
68+ else :
69+ assert False , "should have raise ValueError"
70+
71+ async def test_send_message_to_teams_channels_without_teams_channel_id (self ):
72+ def create_conversation ():
73+ pass
74+
75+ adapter = SimpleAdapterWithCreateConversation (
76+ call_create_conversation = create_conversation
77+ )
78+
79+ activity = Activity (
80+ type = "message" ,
81+ text = "test_send_message_to_teams_channel" ,
82+ channel_id = Channels .ms_teams ,
83+ service_url = "https://example.org" ,
84+ channel_data = TeamsChannelData (team = TeamInfo (id = "team-id" )),
85+ )
86+ turn_context = TurnContext (adapter , activity )
87+
88+ try :
89+ await TeamsInfo .send_message_to_teams_channel (turn_context , activity , "" )
90+ except ValueError :
91+ pass
92+ else :
93+ assert False , "should have raise ValueError"
94+
95+ async def test_send_message_to_teams_channels_without_activity (self ):
96+ def create_conversation ():
97+ pass
98+
99+ adapter = SimpleAdapterWithCreateConversation (
100+ call_create_conversation = create_conversation
101+ )
102+
103+ activity = Activity ()
104+ turn_context = TurnContext (adapter , activity )
105+
106+ try :
107+ await TeamsInfo .send_message_to_teams_channel (turn_context , activity , "" )
108+ except ValueError :
109+ pass
110+ else :
111+ assert False , "should have raise ValueError"
112+
55113
56114class TestTeamsActivityHandler (TeamsActivityHandler ):
57115 async def on_turn (self , turn_context : TurnContext ):
0 commit comments