@@ -16,7 +16,7 @@ class TestPusher(unittest.TestCase):
1616 def setUp (self ):
1717 self .pusher = Pusher (config = Config .from_url (u'http://key:secret@somehost/apps/4' ))
1818
19- def test_trigger_success_case (self ):
19+ def test_trigger_with_channels_list_success_case (self ):
2020 json_dumped = u'{"message": "hello world"}'
2121
2222 with mock .patch ('json.dumps' , return_value = json_dumped ) as json_dumps_mock :
@@ -35,9 +35,24 @@ def test_trigger_success_case(self):
3535
3636 json_dumps_mock .assert_called_once ({u'message' : u'hello world' })
3737
38- def test_trigger_disallow_single_channel (self ):
38+ def test_trigger_with_channel_string_success_case (self ):
39+ json_dumped = u'{"message": "hello world"}'
40+
41+ with mock .patch ('json.dumps' , return_value = json_dumped ) as json_dumps_mock :
42+
43+ request = self .pusher .trigger .make_request (u'some_channel' , u'some_event' , {u'message' : u'hello world' })
44+
45+ expected_params = {
46+ u'channels' : [u'some_channel' ],
47+ u'data' : json_dumped ,
48+ u'name' : u'some_event'
49+ }
50+
51+ self .assertEqual (request .params , expected_params )
52+
53+ def test_trigger_disallow_non_string_or_list_channels (self ):
3954 self .assertRaises (TypeError , lambda :
40- self .pusher .trigger .make_request (u'some_channel' , u'some_event' , {u'message' : u'hello world' }))
55+ self .pusher .trigger .make_request ({ u'channels' : u'test_channel' } , u'some_event' , {u'message' : u'hello world' }))
4156
4257 def test_trigger_disallow_invalid_channels (self ):
4358 self .assertRaises (ValueError , lambda :
0 commit comments