self.assertEqual(mailbox, ['close'])

    def test_request_throttling(self):
        wm = sc.high_ack_count_watermark
        sc.high_ack_count_watermark = 3
        mailbox = []
        try:
            conn = sc.Connection(endpoint, appkey)
            conn.start()

            def callback(ack):
                mailbox.append(ack)

            channel = make_channel_name('request_throttling')
            for i in range(1000):
                conn.publish(channel, 'message', callback=callback)

            time.sleep(2)
        finally:
            conn.stop()
            sc.high_ack_count_watermark = wm

        self.assertEqual(len(mailbox), 1000)
        self.assertTrue(
            all(ack['action'] == 'rtm/publish/ok' for ack in mailbox))


if __name__ == '__main__':
    unittest.main()
    print_resource_usage()
 def test_many_queued_publishes(self):
     client = Client(endpoint=endpoint, appkey=appkey)
     for i in six.moves.range(1000000):
         client.publish(channel=channel, message=message)
     print_resource_usage()
 def test_many_idle_subscriptions(self):
     client = Client(endpoint=endpoint, appkey=appkey)
     for i in six.moves.range(10000):
         client.subscribe(channel='{0}.{1}'.format(channel, i))
     print_resource_usage()
 def test_rapid_stop_start(self):
     client = Client(endpoint=endpoint, appkey=appkey)
     for i in six.moves.range(100):
         client.start()
         client.stop()
     print_resource_usage()