Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Packaging improvements / More producer control (#10)
- Loading branch information
Showing
12 changed files
with
188 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
*.pyc | ||
|
||
/build | ||
/build/ | ||
/dist/ | ||
|
||
/.cache | ||
/.coverage | ||
|
||
*.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
language: python | ||
sudo: false | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
python: | ||
- 2.7 | ||
- 3.5 | ||
- 3.6 | ||
- pypy | ||
|
||
install: false | ||
script: | ||
- pip install -e . | ||
- pip install codecov pytest pytest-mock | ||
- coverage run --source=src $(which py.test) test/ | ||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) | ||
|
||
deploy: | ||
provider: pypi | ||
user: nerdwallet | ||
password: | ||
secure: "Sn+HB7i8sdissJIR5oVtjRG3ek3SkEtVjE/+qbksglUBhCXPPErxtmO5yjPHO0rsux0SE+XkOdTKbiI7Hg+NkK54Slv8GQl5tn9qqi7FY0IoElXqfh/yu6sLk9JZ5aQyhHT6LPsJM9SqP/AjG/+/u00maY0eyNSUzjiEC2ND6djNdQfuViOTX2Co9ojXFN41m4YT6hGmresqfdNK5huIN2nQ4xX9xysohlsCDgCUP4vJ4qF/+aB/ozmJCz1p0HnAprbNgIMIJD9QpAwP3Brikh6YDzLHR6/Wxr/7RtaYrw4BNtTJOe5vzzIoQXSCv89w3dmwcBIyPzlz5+VgequcwLV21+qEJpK/RQL8yszup3aY4VrECzNfQej78x9uBZ7m9XFO1Un9XULDGPFDur4RCIoFsn3I85LSRJIm1IBTNmAnfucRjWvO/EriArlgVQNj8eom0M/8nTPCmU7wU7C36OvCKDb5dSzLlkKYlp3DmfoY39Rjfofn/02XQT/z0GL8a4CkxiU1jnXI+uA+nG0P3b3TudGjai/FVa9qp0nZvgNEBW7syI2XQE8wfkIIN2TLJATzBD3oszeQU4J2SCN86YJVatnR1eQyKn42xfV7MbWf8Dr1A/SqVa8lDrUKaTP2hUzdK3956jfhUo6/pynK1NCMiyRJoJ5hgHVJT2m1sbw=" | ||
on: | ||
branch: master | ||
distributions: "sdist bdist_wheel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.5 | ||
0.1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
boto3==1.4.4 | ||
botocore==1.5.19 # via boto3, s3transfer | ||
docutils==0.13.1 # via botocore | ||
futures==3.0.5 # via s3transfer | ||
jmespath==0.9.1 # via boto3, botocore | ||
boto3==1.4.8 | ||
botocore==1.8.9 # via boto3, s3transfer | ||
docutils==0.14 # via botocore | ||
jmespath==0.9.3 # via boto3, botocore | ||
offspring==0.0.3 | ||
python-dateutil==2.6.0 # via botocore | ||
s3transfer==0.1.10 # via boto3 | ||
six==1.10.0 # via python-dateutil | ||
python-dateutil==2.6.1 # via botocore | ||
s3transfer==0.1.12 # via boto3 | ||
six==1.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
exclude=./venv/*,./build/*,./configs/*,./logs/*,*.egg-info/* | ||
max_line_length=120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from kinesis.consumer import KinesisConsumer | ||
|
||
try: | ||
from unittest.mock import MagicMock | ||
except ImportError: | ||
from mock import MagicMock | ||
|
||
|
||
def test_setup_shards(mocker): | ||
mock_boto3_session = MagicMock() | ||
mock_shard_reader = mocker.patch('kinesis.consumer.ShardReader') | ||
|
||
consumer = KinesisConsumer('testing', boto3_session=mock_boto3_session) | ||
|
||
mock_boto3_session.client.assert_called_with('kinesis') | ||
|
||
consumer.kinesis_client.describe_stream.return_value = { | ||
'StreamDescription': { | ||
'Shards': [ | ||
{ | ||
'ShardId': 'test-shard', | ||
} | ||
] | ||
} | ||
} | ||
consumer.kinesis_client.get_shard_iterator.return_value = { | ||
'ShardIterator': 'test-iter' | ||
} | ||
|
||
consumer.setup_shards() | ||
|
||
consumer.kinesis_client.describe_stream.assert_called_with(StreamName='testing') | ||
consumer.kinesis_client.get_shard_iterator.assert_called_with( | ||
StreamName='testing', | ||
ShardId='test-shard', | ||
ShardIteratorType='LATEST' | ||
) | ||
|
||
mock_shard_reader.assert_called_with( | ||
'test-shard', | ||
'test-iter', | ||
consumer.record_queue, | ||
consumer.error_queue, | ||
boto3_session=consumer.boto3_session, | ||
sleep_time=consumer.reader_sleep_time | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from kinesis.producer import KinesisProducer | ||
|
||
|
||
def test_producer(mocker): | ||
mocked_async_producer = mocker.patch('kinesis.producer.AsyncProducer') | ||
producer = KinesisProducer('testing') | ||
mocked_async_producer.assert_called_with( | ||
'testing', | ||
0.5, | ||
producer.queue, | ||
max_count=None, | ||
max_size=None, | ||
boto3_session=None | ||
) | ||
|
||
mocked_queue = mocker.patch.object(producer, 'queue') | ||
producer.put('foo', explicit_hash_key='hash', partition_key='partition') | ||
mocked_queue.put.assert_called_with(('foo', 'hash', 'partition')) |