Skip to content

Commit

Permalink
Update test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
seedofjoy committed Nov 7, 2022
1 parent 546c03f commit 40ebfef
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Expand Up @@ -21,10 +21,10 @@ jobs:
options: --entrypoint redis-server

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
run: pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.7
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand Down
8 changes: 5 additions & 3 deletions darq/app.py
Expand Up @@ -278,9 +278,11 @@ async def apply_async(
'expires': expires, 'job_try': job_try,
})

self.on_job_prepublish and await self.on_job_prepublish(
metadata, self.registry[name], args, kwargs, job_options,
)
if self.on_job_prepublish:
await self.on_job_prepublish(
metadata, self.registry[name], args, kwargs,
job_options,
)
if metadata:
kwargs['__metadata__'] = metadata
return await self.redis_pool.enqueue_job(
Expand Down
2 changes: 1 addition & 1 deletion examples/aiohttp/requirements.txt
@@ -1,2 +1,2 @@
aiohttp>=3.7.4,<4.0.0
darq==0.10
darq==0.11.0
21 changes: 10 additions & 11 deletions tests/requirements.txt
@@ -1,16 +1,15 @@
pytest==6.2.5
pytest-aiohttp==1.0.3
pytest-mock==3.6.1
pytest-toolbox==0.4
pytest-cov==3.0.0
pytest==7.2.0
pytest-aiohttp==1.0.4
pytest-mock==3.10.0
pytest-cov==4.0.0
asynctest==0.13.0
mypy==0.931
flake8==4.0.1
mypy==0.982
flake8==5.0.4
flake8-quotes==3.3.1
flake8-bugbear==22.1.11
flake8-builtins==1.5.3
flake8-bugbear==22.10.27
flake8-builtins==2.0.0
flake8-import-order==0.18.1
flake8-print==4.0.0
flake8-print==5.0.0
flake8-commas==2.1.0
typing_extensions==4.0 # pyup: ignore # it should be minimal version from setup.py
msgpack==1.0.3
msgpack==1.0.4
2 changes: 1 addition & 1 deletion tests/test_jobs.py
Expand Up @@ -2,7 +2,6 @@
import pickle

import pytest
from pytest_toolbox.comparison import CloseToNow

from darq.constants import default_queue_name
from darq.constants import in_progress_key_prefix
Expand All @@ -14,6 +13,7 @@
from darq.jobs import JobResult
from darq.jobs import JobStatus
from darq.jobs import serialize_result
from .utils import CloseToNow


async def test_job_in_progress(arq_redis):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Expand Up @@ -7,8 +7,6 @@
from time import time

import pytest
from pytest_toolbox.comparison import AnyInt
from pytest_toolbox.comparison import CloseToNow

from darq.constants import default_queue_name
from darq.jobs import Job
Expand All @@ -17,6 +15,8 @@
from darq.utils import timestamp_ms
from darq.worker import Retry
from darq.worker import Worker
from .utils import AnyInt
from .utils import CloseToNow


async def foobar():
Expand Down
44 changes: 44 additions & 0 deletions tests/utils.py
@@ -0,0 +1,44 @@
from datetime import datetime
from datetime import timezone


class CloseToNow:
def __init__(self, delta=2):
self.delta: float = delta
self.now = datetime.utcnow()
self.match = False
self.other = None

def __eq__(self, other):
self.other = other
if other.tzinfo:
self.now = self.now.replace(tzinfo=timezone.utc)
self.match = (
-self.delta < (self.now - other).total_seconds() < self.delta)
return self.match

def __repr__(self):
if self.match:
# if we've got the correct value return it to aid in diffs
return repr(self.other)

return (
f'<CloseToNow(delta={self.delta}, '
f'now={self.now:%Y-%m-%dT%H:%M:%S})>'
)


class AnyInt:
def __init__(self):
self.v = None

def __eq__(self, other):
if type(other) == int:
self.v = other
return True

def __repr__(self):
if self.v is None:
return '<AnyInt>'
else:
return repr(self.v)

0 comments on commit 40ebfef

Please sign in to comment.