def test_send_and_download_file(event_loop, file_for_upload): pubnub = PubNubAsyncio(pnconf_file_copy(), custom_event_loop=event_loop) envelope = yield from send_file(pubnub, file_for_upload) download_envelope = yield from pubnub.download_file().\ channel(CHANNEL).\ file_id(envelope.result.file_id).\ file_name(envelope.result.name).future() assert isinstance(download_envelope.result, PNDownloadFileResult) pubnub.stop()
def test_send_and_download_file_encrypted(event_loop, file_for_upload, file_upload_test_data): pubnub = PubNubAsyncio(pnconf_file_copy(), custom_event_loop=event_loop) envelope = yield from send_file(pubnub, file_for_upload, cipher_key="test") download_envelope = yield from pubnub.download_file().\ channel(CHANNEL).\ file_id(envelope.result.file_id).\ file_name(envelope.result.name).\ cipher_key("test").\ future() assert isinstance(download_envelope.result, PNDownloadFileResult) assert download_envelope.result.data == bytes(file_upload_test_data["FILE_CONTENT"], "utf-8") pubnub.stop()