Skip to content

Commit

Permalink
upreving
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Dec 6, 2016
1 parent 47e8e9a commit 70a76ec
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: install
install:
pip install -U pip
pip install -U pip setuptools
pip install -e .
pip install -Ur tests/requirements.txt
pip install -r tests/requirements.txt

.PHONY: isort
isort:
Expand All @@ -13,11 +13,12 @@ isort:
lint:
python setup.py check -rms
flake8 arq/ tests/
pytest arq -p no:sugar -q --cache-clear
mypy --fast-parser --silent-imports arq/

.PHONY: test
test:
py.test --cov=arq --isort && coverage combine
py.test --cov=arq && coverage combine

.PHONY: .test-build-cov
.test-build-cov:
Expand Down
6 changes: 3 additions & 3 deletions arq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def to_unix_ms(dt: datetime) -> Tuple[int, int]:
"""
utcoffset = dt.utcoffset()
if utcoffset is not None:
utcoffset = utcoffset.total_seconds() # type: ignore # TODO fix after python/typeshed#554
unix = (dt - EPOCH_TZ).total_seconds() + utcoffset
return int(unix * 1000), int(utcoffset)
_utcoffset = utcoffset.total_seconds()
unix = (dt - EPOCH_TZ).total_seconds() + _utcoffset
return int(unix * 1000), int(_utcoffset)
else:
return int((dt - EPOCH).total_seconds() * 1000), None

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool:pytest]
testpaths = tests
addopts = --isort

[flake8]
max-line-length = 120
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
arq=arq.cli:cli
""",
install_requires=[
'aioredis>=0.2.8',
'aioredis>=0.2.9',
'click>=6.6',
'msgpack-python>=0.4.8',
],
extras_require={
'testing': ['pytest>=2.9.2'],
'testing': ['pytest>=3.0.5'],
},
)
30 changes: 15 additions & 15 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
codecov
coverage
docutils
flake8
isort
ghp-import
mypy-lang
pep8
pytest
pytest-cov
pytest-isort
pytest-sugar
pytz
sphinx
typed-ast
coverage==4.2
docutils==0.12
flake8==3.2.1
ghp-import==0.4.1
mypy-lang==0.4.6
pycodestyle==2.2.0
pyflakes==1.3.0
pytest==3.0.5
pytest-aiohttp==0.1.3
pytest-cov==2.4.0
pytest-isort==0.1.0
pytest-sugar==0.7.1
pytz==2016.10
Sphinx==1.4.6
typed-ast==0.6.1
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from .fixtures import DemoActor, FoobarActor, MockRedisDemoActor, MockRedisWorker


async def test_simple_job_dispatch(loop, debug):
actor = MockRedisDemoActor(loop=loop)
assert None is await actor.add_numbers(1, 2)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .fixtures import (EXAMPLE_FILE, DemoActor, FoobarActor, MockRedisDemoActor, MockRedisWorker, MockRedisWorkerQuit,
Worker, WorkerFail, WorkerQuit, kill_parent)


async def test_run_job_burst(tmpworkdir, redis_conn, actor):
worker = Worker(burst=True, loop=actor.loop)

Expand Down Expand Up @@ -46,6 +47,7 @@ async def test_seperate_log_levels(mock_actor_worker, caplog):
'arq.work: shutting down worker, waiting for 1 jobs to finish\n'
'arq.work: shutting down worker after 0.0XXs ◆ 1 jobs done ◆ 0 failed ◆ 0 timed out\n') == log


async def test_wrong_worker(mock_actor_worker, loop, caplog):
actor, worker = mock_actor_worker
actor2 = FoobarActor(loop=loop)
Expand All @@ -55,6 +57,7 @@ async def test_wrong_worker(mock_actor_worker, loop, caplog):
assert worker.jobs_failed == 1
assert 'Job Error: unable to find shadow for <Job foobar.concat(a, b) on dft>' in caplog


async def test_queue_not_found(loop):
worker = MockRedisWorkerQuit(loop=loop, queues=['foobar'])
with pytest.raises(KeyError) as excinfo:
Expand Down

0 comments on commit 70a76ec

Please sign in to comment.