Пример #1
0
    def test_exception_in_solicited_pdu_callback(self):

        observer = ClientObserver()

        with make_client(endpoint=endpoint, appkey=appkey,
                         observer=observer) as client:

            def crashy(ack):
                print(ack["no-such-field"])

            observer.stopped.clear()
            client.publish(channel, 'message', callback=crashy)
            observer.wait_stopped()
 def test_before_start(self):
     client = Client(endpoint=endpoint, appkey=appkey)
     co = ClientObserver()
     client.observer = co
     so = SubscriptionObserver()
     client.subscribe(channel,
                      SubscriptionMode.ADVANCED,
                      subscription_observer=so)
     client.start()
     co.wait_connected()
     sync_publish(client, channel, 'message')
     channel_data = so.wait_for_channel_data()
     self.assertEqual(channel_data['messages'], ['message'])
     client.stop()
     co.wait_stopped()
Пример #3
0
    def test_exception_in_subscription_data_callback(self):

        observer = ClientObserver()

        with make_client(endpoint=endpoint, appkey=appkey,
                         observer=observer) as client:

            class CrashyObserver(SubscriptionObserver):
                def on_subscription_data(this, data):
                    SubscriptionObserver.on_subscription_data(this, data)
                    raise ValueError('Error in on_subscription_data')

            observer.stopped.clear()
            so = CrashyObserver()
            client.subscribe(channel, SubscriptionMode.SIMPLE, so)
            so.wait_subscribed()
            client.publish(channel, 'message')
            observer.wait_stopped()