Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
58 lines (47 sloc) 1.84 KB
from .test_base import BaseTestCase
import time
import json
import os
from ringcentral_client import PubNub
class SubscriptionTestCase(BaseTestCase):
def setUp(self):
super(SubscriptionTestCase, self).setUp()
# subscribe
events = [
self.subscription = PubNub(self.rc, events, self.message_callback)
def message_callback(self, message):
self.count += 1
def test_pubnub_sms(self):
self.count = 0
# refresh
# call refresh manually shouldn't break anything
# send an SMS to tigger a notification
data = {
'from': { 'phoneNumber': self.username },
'to': [{ 'phoneNumber': self.receiver }],
'text': 'hello world'
}'/restapi/v1.0/account/~/extension/~/sms', data)
# wait for the notification to come
self.assertGreater(self.count, 0)
def test_pubnub_fax(self):
self.count = 0
# send an fax to tigger a notification
with open(os.path.join(os.path.dirname(__file__), 'test.png'), 'rb') as image_file:
files = [
('json', ('request.json', json.dumps({ 'to': [{ 'phoneNumber': self.receiver }] }), 'application/json')),
('attachment', ('test.txt', 'Hello world', 'text/plain')),
('attachment', ('test.png', image_file, 'image/png')),
]'/restapi/v1.0/account/~/extension/~/fax', files = files)
# wait for the notification to come
self.assertGreater(self.count, 0)
def tearDown(self):
super(SubscriptionTestCase, self).tearDown()
You can’t perform that action at this time.