Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuejunior committed Dec 23, 2017
2 parents a8780e8 + 46e3184 commit 9197560
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 20 deletions.
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -75,9 +75,17 @@ Then

### Developing mode

Run tests
Running tests

To run the project's test you will need to have pytest installed. The instalation is simple as :

```shell
$ pip install pytest
```

And to run the tests you need to ajust yout `PYTHONPATH`

```shell
$ py.test
$ PYTHONPATH=equeue py.test
```

2 changes: 1 addition & 1 deletion equeue/__init__.py
@@ -1 +1 @@
__version__ = '0.1.4'
__version__ = '0.1.5'
2 changes: 1 addition & 1 deletion equeue/rabbit/publisher.py
@@ -1,7 +1,7 @@
# encondign: utf-8
import simplejson as json
from amqp import Message
from rabbit.queue import RabbitQueue, SerializationError
from equeue.rabbit.queue import RabbitQueue, SerializationError


class Publisher(RabbitQueue):
Expand Down
4 changes: 2 additions & 2 deletions equeue/rabbit/queue.py
@@ -1,10 +1,10 @@
from datetime import datetime
import time
import uuid
from datetime import datetime

import simplejson as json
import amqp
from amqp import Message, AMQPError, ConnectionError as AMQPConnectionError
import simplejson as json

MAX_TRIES = 3
META_FIELD = "_meta"
Expand Down
2 changes: 1 addition & 1 deletion equeue/rabbit/subscriber.py
@@ -1,6 +1,6 @@
# enconding: utf-8
import time
from rabbit.queue import RabbitQueue
from equeue.rabbit.queue import RabbitQueue


class Subscriber(RabbitQueue):
Expand Down
4 changes: 4 additions & 0 deletions requirements-dev.txt
@@ -0,0 +1,4 @@
mock==2.0.0
pytest==3.0.3
pytest-cov==2.3.1

2 changes: 2 additions & 0 deletions requirements.txt
@@ -0,0 +1,2 @@
amqp==2.1.0
simplejson==3.8.2
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -18,8 +18,8 @@
packages=find_packages(),
install_requires=['amqp==2.1.0', 'simplejson>=3.8.2', 'six==1.10.0'],
test_suite='tests',
tests_require=['tox>=2.3.1'] + (
['mock==1.3.0'] if sys.version_info.major == 2 else []
tests_require=['tox>=2.3.1', 'pytest==3.0.3', 'pytest-cov==2.3.1'] + (
['mock==2.0.0'] if sys.version_info.major == 2 else []
),
classifiers=[
'Intended Audience :: Developers',
Expand Down
Empty file added tests/__init__.py
Empty file.
@@ -1,12 +1,13 @@
from datetime import datetime
import json
#encoding: utf-8
import unittest
from datetime import datetime

import simplejson as json
from amqp import Message, AMQPError, ConnectionError
from mock import MagicMock, patch, call, Mock, ANY

from rabbit.queue import SerializationError
from rabbit.publisher import Publisher
from equeue.rabbit.queue import SerializationError
from equeue.rabbit.publisher import Publisher


class RabbitQueueTest(unittest.TestCase):
Expand Down Expand Up @@ -44,7 +45,7 @@ def test_put_default_exchange_if_not_supplied(self):

def test_put_serializes_message_if_necessary(self):
message = {'key': 'value'}
with patch('rabbit.publisher.Publisher') as MockPublisher:
with patch('equeue.rabbit.publisher.Publisher') as MockPublisher:
self.publisher.put(message_dict=message)

self.assertEqual(MockPublisher.call_args_list,
Expand Down
@@ -1,13 +1,14 @@
from datetime import datetime
import json
#encoding: utf-8
import unittest
from datetime import datetime

import simplejson as json
from amqp import Message, AMQPError, ConnectionError
from mock import MagicMock, patch, call, Mock, ANY

from rabbit.queue import (RabbitQueue, MAX_TRIES, SerializationError, META_FIELD)
from equeue.rabbit.queue import (RabbitQueue, MAX_TRIES, SerializationError, META_FIELD)

MODULE = 'rabbit.queue.'
MODULE = 'equeue.rabbit.queue.'


class RabbitQueueTest(unittest.TestCase):
Expand Down
Expand Up @@ -5,7 +5,7 @@
from amqp import Message, AMQPError, ConnectionError
from mock import MagicMock, patch, call, Mock, ANY

from rabbit.subscriber import Subscriber
from equeue.rabbit.subscriber import Subscriber


class SubscriberTest(unittest.TestCase):
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_get_sleeps_and_tries_again_until_queue_is_not_empty(self):
empty_rv = None
self.channel_mock.basic_get.side_effect = [empty_rv, empty_rv, self.message]
with patch('time.sleep') as sleep,\
patch('rabbit.queue.RabbitQueue._parse_message') as parse_message_mock:
patch('equeue.rabbit.queue.RabbitQueue._parse_message') as parse_message_mock:
message = self.subscriber.get(queue_name='queue_name')

self.assertEqual(message, parse_message_mock.return_value)
Expand Down

0 comments on commit 9197560

Please sign in to comment.