Skip to content

Commit a62a48e

Browse files
committed
adding some attributes stuff, adding dbg helper to tests
1 parent 0ccc430 commit a62a48e

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ deploy:
2222
on:
2323
branch: master
2424
tags: true
25+
password:
26+
secure: cmGJerE74ddOd3WXFgOvb2hhFG8ohmkszuzEUoV4c65O1V0UkTIgul0xnRmKamyZbhx0py63yKo9fRyiPOmKOksp444MCMlJ/LaS1wfgfWEXjNRD0pxGfG6Do+NM+L25yEPv7VANTPpPXMEXy0dwf1DYv9EwLh/7p8mbsGhxM24vgxCLt30NFuOofnuYWg+fp3T5RExXInDDDf393932AV792bFJxv8XpUceThytzfgQh2pum43ZKemWRDk8tpAE9Qq0BL/KyNDkf83aV/ZxAomH+jT3EN1QMS1QdNKGVMx7kbXVn6nEzOG5/7h1EzGVcj08xrhLxZtUv/dD6IwX8LrE95egP9xT2JjUS2DKiS8nIW+Rmf0yPNtl+FjUjwqm5BNOzDye0czCLQiVuC1BPvhStw4QxPvbLFcZ0dEKCZPhX6F8vxoLa2belRgqr1FKFMyZVYuYJmGZru4/G4T8Pp3dClflK/TrYdLBA+Jtuwo8R3p3zy7VWwkPNfk+Xo2H9LRO5y7X9bToichTDmIfhOhxtNVhPyElyRdnIAmdYwLQS18FlrddtzCeNgrc8grN8R0rPBthI2d+z6K+IFMghka4NgFqGxUYUp6ZAwzWXcgqN+IUeS17XIM1z7wrMzg33njLiLUSWoZ8CN2czXKXefFcdd07n/dCk5yBFaV3Eb8=

qoo/queues.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
queue class
2+
qoo queue and job class
33
"""
44
import boto3
55
import os
@@ -19,8 +19,12 @@ def __init__(self, sqs_message: dict, queue: "Queue") -> None:
1919
self._md5 = self._data["MD5OfBody"]
2020
self._id = self._data["MessageId"]
2121
self._body = jsonl(self._data["Body"])
22+
self._attributes = self._data["Attributes"]
2223
self._received_at = float(time.time())
2324
self.elapsed = time.time() - self._body["created_at"]
25+
self.approximate_receive_count = int(
26+
self._attributes["ApproximateReceiveCount"]
27+
)
2428
for key in self._body:
2529
setattr(self, key, self._body[key])
2630
self.handle = self._data["ReceiptHandle"]

setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ ignore_missing_imports = True
77
ignore = N802,N807,W503
88
max-line-length = 100
99
max-complexity = 20
10+
11+
[tool:pytest]
12+
log_print = False

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def queue() -> Generator:
3131
def fifo_queue() -> Generator:
3232
"""fixture that provides a fifo SQS qoo."""
3333
with mock_sqs():
34-
yield qoo.create("qoo-fifo", fifo=True)
34+
yield qoo.create("qoo.fifo", fifo=True)
3535

3636

3737
@pytest.fixture

tests/test_qoo.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
"""
22
pytest the qoo functionality
33
"""
4+
import json
45
import os
5-
import qoo
66
import pytest
7+
import qoo
8+
import sys
79
import time
810
from moto import mock_sqs
911

1012

13+
def dbg(text):
14+
"""debug printer for tests"""
15+
if isinstance(text, dict):
16+
text = json.dumps(text, sort_keys=True, indent=2)
17+
caller = sys._getframe(1)
18+
print("")
19+
print("----- {} line {} ------".format(caller.f_code.co_name, caller.f_lineno))
20+
print(text)
21+
print("-----")
22+
print("")
23+
24+
1125
def test_login():
1226
"""
1327
Ensure that login sets the correct environment variables.
@@ -32,8 +46,8 @@ def test_queues_can_be_created():
3246
@mock_sqs
3347
def test_fifo_queues_can_be_created():
3448
"""test that we can create a queue"""
35-
queue = qoo.create("test_queue", fifo=True)
36-
assert queue.name == "test_queue"
49+
queue = qoo.create("test_queue.fifo", fifo=True)
50+
assert queue.name == "test_queue.fifo"
3751
assert queue.created_at < time.time()
3852
assert queue.maximum_message_size == 262144
3953
assert queue.fifo
@@ -60,6 +74,7 @@ def test_can_send_and_receive_job(queue):
6074
job = queue.receive()
6175
assert job
6276
assert job.md5_matches
77+
assert job.approximate_receive_count == 1
6378

6479

6580
def test_can_delete_job(queue_with_job):

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ envlist = py{35,36,37}
33

44
[testenv]
55
commands =
6-
pytest --cov qoo --cov-report term []
6+
pytest -s --cov qoo --cov-report term []
77
deps =
88
pytest
99
pytest-cov

0 commit comments

Comments
 (0)