def test_encrypted(self): ch = "history-native-sync-ch" pubnub = PubNub(pnconf_enc_copy()) pubnub.config.uuid = "history-native-sync-uuid" for i in range(COUNT): envelope = pubnub.publish().channel(ch).message("hey-%s" % i).sync() assert isinstance(envelope.result, PNPublishResult) assert envelope.result.timetoken > 0 time.sleep(5) envelope = pubnub.history().channel(ch).count(COUNT).sync() assert isinstance(envelope.result, PNHistoryResult) assert envelope.result.start_timetoken > 0 assert envelope.result.end_timetoken > 0 assert len(envelope.result.messages) == 5 assert envelope.result.messages[0].entry == 'hey-0' assert envelope.result.messages[1].entry == 'hey-1' assert envelope.result.messages[2].entry == 'hey-2' assert envelope.result.messages[3].entry == 'hey-3' assert envelope.result.messages[4].entry == 'hey-4'
def test_publish_mixed_via_post_encrypted(event_loop): pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop) yield from asyncio.gather( asyncio.ensure_future(assert_success_publish_post(pubnub, "hi")), asyncio.ensure_future(assert_success_publish_post(pubnub, 5)), asyncio.ensure_future(assert_success_publish_post(pubnub, True)), asyncio.ensure_future(assert_success_publish_post(pubnub, ["hi", "hi2", "hi3"]))) pubnub.stop()
async def test_publish_object_via_post_encrypted(event_loop): pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop) await asyncio.ensure_future( assert_success_publish_post(pubnub, { "name": "Alex", "online": True })) await pubnub.stop()
async def test_publish_mixed_via_get_encrypted(event_loop): with patch("pubnub.crypto.PubNubCryptodome.get_initialization_vector", return_value="knightsofni12345"): pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop) await asyncio.gather( asyncio.ensure_future(assert_success_publish_get(pubnub, "hi")), asyncio.ensure_future(assert_success_publish_get(pubnub, 5)), asyncio.ensure_future(assert_success_publish_get(pubnub, True)), asyncio.ensure_future(assert_success_publish_get(pubnub, ["hi", "hi2", "hi3"]))) await pubnub.stop()
def test_publish_object_via_post_encrypted(event_loop): pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop) yield from asyncio.ensure_future(assert_success_publish_post(pubnub, {"name": "Alex", "online": True})) pubnub.stop()
def assert_success_encrypted_publish_get(self, message): pubnub = PubNubTwisted(pnconf_enc_copy()) publish = pubnub.publish().channel(channel).message(message) envelope = yield self.deferred(publish) self.assert_valid_publish_envelope(envelope) returnValue(envelope)
async def test_publish_object_via_post_encrypted(event_loop): with patch("pubnub.crypto.PubNubCryptodome.get_initialization_vector", return_value="knightsofni12345"): pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop) await asyncio.ensure_future(assert_success_publish_post(pubnub, {"name": "Alex", "online": True})) await pubnub.stop()