Exemplo n.º 1
0
    def test_callbacks(self):
        pn = _pubnub()
        subscribe_listener = SubscribeListener()
        pn.add_listener(subscribe_listener)

        test_channel = "test_ch1_%s" % utils.uuid()

        pn.subscribe() \
            .channels([test_channel]) \
            .execute()

        subscribe_listener.wait_for_connect()

        pn.set_channel_metadata() \
            .channel(test_channel) \
            .set_name("The channel %s" + utils.uuid()) \
            .sync()

        pn.set_memberships() \
            .channel_memberships([PNChannelMembership.channel(test_channel)]) \
            .sync()

        pn.set_uuid_metadata() \
            .set_name("Some Name %s" + utils.uuid()) \
            .email("*****@*****.**") \
            .sync()

        membership_result = subscribe_listener.membership_queue.get(block=True,
                                                                    timeout=10)
        channel_result = subscribe_listener.channel_queue.get(block=True,
                                                              timeout=10)
        uuid_result = subscribe_listener.uuid_queue.get(block=True, timeout=10)

        assert membership_result is not None
        assert channel_result is not None
        assert uuid_result is not None
Exemplo n.º 2
0
Arquivo: app.py Projeto: pubnub/python
d = os.path.dirname
PUBNUB_ROOT = d(d(d(os.path.dirname(os.path.abspath(__file__)))))
APP_ROOT = d(os.path.abspath(__file__))
sys.path.append(PUBNUB_ROOT)


from pubnub.exceptions import PubNubException
from pubnub.pnconfiguration import PNConfiguration

pnconf = PNConfiguration()
pnconf.subscribe_key = "sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe"
pnconf.publish_key = "pub-c-739aa0fc-3ed5-472b-af26-aca1b333ec52"
pnconf.uuid = "pubnub-demo-api-python-backend"
DEFAULT_CHANNEL = "pubnub_demo_api_python_channel"
EVENTS_CHANNEL = "pubnub_demo_api_python_events"
APP_KEY = utils.uuid()

loop = asyncio.get_event_loop()
pubnub = PubNubAsyncio(pnconf)


def publish_sync():
    return _not_implemented_error({
        "error": "Sync publish not implemented"
    })


def app_key_handler():
    return _ok({
        'app_key': APP_KEY
    })
Exemplo n.º 3
0
 def test_uuid(self):
     assert isinstance(utils.uuid(), str)
     assert len(utils.uuid()) == 36
Exemplo n.º 4
0
 def test_uuid(self):
     assert isinstance(utils.uuid(), str)
     assert len(utils.uuid()) == 36
Exemplo n.º 5
0
d = os.path.dirname
PUBNUB_ROOT = d(d(d(os.path.dirname(os.path.abspath(__file__)))))
APP_ROOT = d(os.path.abspath(__file__))
sys.path.append(PUBNUB_ROOT)

from pubnub.exceptions import PubNubException
from pubnub.pnconfiguration import PNConfiguration

pnconf = PNConfiguration()
pnconf.subscribe_key = "sub-c-33f55052-190b-11e6-bfbc-02ee2ddab7fe"
pnconf.publish_key = "pub-c-739aa0fc-3ed5-472b-af26-aca1b333ec52"
pnconf.uuid = "pubnub-demo-api-python-backend"
DEFAULT_CHANNEL = "pubnub_demo_api_python_channel"
EVENTS_CHANNEL = "pubnub_demo_api_python_events"
APP_KEY = utils.uuid()

loop = asyncio.get_event_loop()
pubnub = PubNubAsyncio(pnconf)


def publish_sync():
    return _not_implemented_error({"error": "Sync publish not implemented"})


def app_key_handler():
    return _ok({'app_key': APP_KEY})


def list_channels_handler():
    return _ok({"subscribed_channels": pubnub.get_subscribed_channels()})