|
10 | 10 | Mention,
|
11 | 11 | ResourceResponse,
|
12 | 12 | )
|
13 |
| -from botbuilder.core import BotAdapter, TurnContext |
| 13 | +from botbuilder.core import BotAdapter, MessageFactory, TurnContext |
14 | 14 |
|
15 | 15 | ACTIVITY = Activity(
|
16 | 16 | id="1234",
|
@@ -40,11 +40,12 @@ async def send_activities(self, context, activities):
|
40 | 40 | async def update_activity(self, context, activity):
|
41 | 41 | assert context is not None
|
42 | 42 | assert activity is not None
|
| 43 | + return ResourceResponse(id=activity.id) |
43 | 44 |
|
44 | 45 | async def delete_activity(self, context, reference):
|
45 | 46 | assert context is not None
|
46 | 47 | assert reference is not None
|
47 |
| - assert reference.activity_id == "1234" |
| 48 | + assert reference.activity_id == ACTIVITY.id |
48 | 49 |
|
49 | 50 |
|
50 | 51 | class TestBotContext(aiounittest.AsyncTestCase):
|
@@ -225,6 +226,26 @@ async def update_handler(context, activity, next_handler_coroutine):
|
225 | 226 | await context.update_activity(ACTIVITY)
|
226 | 227 | assert called is True
|
227 | 228 |
|
| 229 | + async def test_update_activity_should_apply_conversation_reference(self): |
| 230 | + activity_id = "activity ID" |
| 231 | + context = TurnContext(SimpleAdapter(), ACTIVITY) |
| 232 | + called = False |
| 233 | + |
| 234 | + async def update_handler(context, activity, next_handler_coroutine): |
| 235 | + nonlocal called |
| 236 | + called = True |
| 237 | + assert context is not None |
| 238 | + assert activity.id == activity_id |
| 239 | + assert activity.conversation.id == ACTIVITY.conversation.id |
| 240 | + await next_handler_coroutine() |
| 241 | + |
| 242 | + context.on_update_activity(update_handler) |
| 243 | + new_activity = MessageFactory.text("test text") |
| 244 | + new_activity.id = activity_id |
| 245 | + update_result = await context.update_activity(new_activity) |
| 246 | + assert called is True |
| 247 | + assert update_result.id == activity_id |
| 248 | + |
228 | 249 | def test_get_conversation_reference_should_return_valid_reference(self):
|
229 | 250 | reference = TurnContext.get_conversation_reference(ACTIVITY)
|
230 | 251 |
|
|
0 commit comments