diff --git a/setup.py b/setup.py index 9dd7ca688040f5365a244e59db9f337aae189a3a..554ba11a93740b172e4a7ca4ab5c03abfbf3a081 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,25 @@ #!/usr/bin/env python -#coding=UTF-8 -from distutils.core import setup +# coding=UTF-8 +from setuptools import setup setup(name='CoolAMQP', - version='0.6', - description=u'The reconnecting AMQP client', + version='0.7', + description=u'AMQP client with sane reconnects', author=u'DMS Serwis s.c.', author_email='piotrm@smok.co', url='https://github.com/smok-serwis/coolamqp', - download_url='https://github.com/smok-serwis/coolamqp/archive/master.zip', + download_url='https://github.com/smok-serwis/coolamqp/archive/v0.7.zip', keywords=['amqp', 'pyamqp', 'rabbitmq', 'client', 'network', 'ha', 'high availability'], packages=['coolamqp', 'coolamqp.backends'], license='MIT License', long_description=u'The AMQP client that handles reconnection madness for you', requires=[ "amqp", - "six" + "six", + "monotonic" ], + tests_require=["nose"], + test_suite='nose.collector', classifiers=[ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', @@ -26,4 +29,4 @@ setup(name='CoolAMQP', 'Programming Language :: Python :: Implementation :: PyPy', 'Operating System :: OS Independent' ] - ) \ No newline at end of file + ) diff --git a/tests/test_performance.py b/tests/test_performance.py new file mode 100644 index 0000000000000000000000000000000000000000..034c623630314c17f7513346712f9283d9b4195a --- /dev/null +++ b/tests/test_performance.py @@ -0,0 +1,46 @@ +#coding=UTF-8 +from __future__ import absolute_import, division, print_function +import unittest +import six +import time + +from coolamqp import Cluster, ClusterNode, Queue, MessageReceived, ConnectionUp, \ + ConnectionDown, ConsumerCancelled, Message, Exchange + + +class TestBasics(unittest.TestCase): + def setUp(self): + self.amqp = Cluster([ClusterNode('127.0.0.1', 'guest', 'guest')]) + self.amqp.start() + self.assertIsInstance(self.amqp.drain(1), ConnectionUp) + + def tearDown(self): + self.amqp.shutdown() + + def takes_less_than(self, max_time): + """ + Tests that your code executes in less time than specified value. + Use like: + + with self.takes_less_than(0.9): + my_operation() + + :param max_time: in seconds + """ + test = self + + class CM(object): + def __enter__(self): + self.started_at = time.time() + + def __exit__(self, tp, v, tb): + test.assertLess(time.time() - self.started_at, max_time) + return False + + return CM() + + def test_sending_a_message(self): + + with self.takes_less_than(0.5): + self.amqp.send(Message(''), routing_key='nowhere').result() +