11import unittest
2+ import json
23from datetime import datetime
34from messagebird import Client
45from messagebird .conversation_webhook import \
@@ -62,3 +63,26 @@ def test_conversation_webhook_read(self):
6263 self .assertEqual (datetime (2019 , 4 , 3 , 8 , 41 , 37 ), web_hook .createdDatetime )
6364 self .assertEqual (None , web_hook .updatedDatetime )
6465 self .assertEqual (['conversation.created' , 'conversation.updated' ], web_hook .events )
66+
67+ def test_conversation_webhook_update (self ):
68+ http_client = Mock ()
69+ http_client .request .return_value = json .dumps ({"id" : "985ae50937a94c64b392531ea87a0263" ,
70+ "url" : "https://example.com/webhook" ,
71+ "channelId" : "853eeb5348e541a595da93b48c61a1ae" ,
72+ "events" : [
73+ "message.created" ,
74+ "message.updated" ,
75+ ],
76+ "status" : "enabled" ,
77+ "createdDatetime" : "2018-08-29T10:04:23Z" ,
78+ "updatedDatetime" : "2018-08-29T10:10:23Z"
79+ })
80+
81+ webhookRequestData = {
82+ 'events' : [CONVERSATION_WEBHOOK_EVENT_CONVERSATION_CREATED ,
83+ CONVERSATION_WEBHOOK_EVENT_CONVERSATION_UPDATED ],
84+ 'url' : 'https://example.com/webhook' ,
85+ 'status' : 'enabled'
86+ }
87+ web_hook = Client ('' , http_client ).conversation_update_webhook ('webhook-id' , webhookRequestData )
88+ http_client .request .assert_called_once_with ('webhooks/webhook-id' , 'PATCH' , webhookRequestData )
0 commit comments