Exemple #1
0
def test_publish_file_message():
    envelope = PublishFileMessage(pubnub).\
        channel(CHANNEL).\
        meta({}).\
        message({"test": "test"}).\
        file_id("2222").\
        file_name("test").\
        should_store(True).\
        ttl(222).sync()

    assert isinstance(envelope.result, PNPublishFileMessageResult)
Exemple #2
0
def test_publish_file_message_with_encryption(event_loop, file_upload_test_data):
    pubnub = PubNubAsyncio(pnconf_file_copy(), custom_event_loop=event_loop)
    envelope = yield from PublishFileMessage(pubnub).\
        channel(CHANNEL).\
        meta({}).\
        message({"test": "test"}).\
        file_id("2222").\
        file_name("test").\
        should_store(True).\
        ttl(222).future()

    assert isinstance(envelope.result, PNPublishFileMessageResult)
    pubnub.stop()
    def test_publish_file_message(self):
        PublishFileMessage(pubnub).\
            channel(CHANNEL).\
            meta({}).\
            message({"test": "test"}).\
            file_id("2222").\
            file_name("test").\
            should_store(True).\
            ttl(222).pn_async(self.callback)

        self.event.wait()
        assert not self.status.is_error()
        assert isinstance(self.response, PNPublishFileMessageResult)
Exemple #4
0
def test_publish_file_message_with_overriding_time_token():
    timetoken_to_override = 16057799474000000
    envelope = PublishFileMessage(pubnub).\
        channel(CHANNEL).\
        meta({}).\
        message({"test": "test"}).\
        file_id("2222").\
        file_name("test").\
        should_store(True).\
        replicate(True).\
        ptto(timetoken_to_override).\
        ttl(222).sync()

    assert isinstance(envelope.result, PNPublishFileMessageResult)
    assert "ptto" in envelope.status.client_request.url
Exemple #5
0
    def future(self):
        self._file_upload_envelope = yield from FetchFileUploadS3Data(self._pubnub).\
            channel(self._channel).\
            file_name(self._file_name).future()

        response_envelope = yield from super(SendFileNative, self).future()

        publish_file_response = yield from PublishFileMessage(self._pubnub).\
            channel(self._channel).\
            meta(self._meta).\
            message(self._message).\
            file_id(response_envelope.result.file_id).\
            file_name(response_envelope.result.name).\
            should_store(self._should_store).\
            ttl(self._ttl).\
            cipher_key(self._cipher_key).future()

        response_envelope.result.timestamp = publish_file_response.result.timestamp
        return response_envelope
Exemple #6
0
    def sync(self):
        self._file_upload_envelope = FetchFileUploadS3Data(self._pubnub).\
            channel(self._channel).\
            file_name(self._file_name).sync()

        response_envelope = super(SendFileNative, self).sync()

        publish_file_response = PublishFileMessage(self._pubnub).\
            channel(self._channel).\
            meta(self._meta).\
            message(self._message).\
            file_id(response_envelope.result.file_id).\
            file_name(response_envelope.result.name).\
            should_store(self._should_store).\
            ttl(self._ttl).\
            replicate(self._replicate).\
            ptto(self._ptto).\
            cipher_key(self._cipher_key).sync()

        response_envelope.result.timestamp = publish_file_response.result.timestamp
        return response_envelope