Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Django 5 and Python 3.12 to test matrix #62

Merged
merged 6 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,29 @@ jobs:

strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
django: ["3.2", "4.0", "4.1", "4.2"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django: ["3.2", "4.0", "4.1", "4.2", "5.0"]
exclude:
- python: "3.11"
django: "3.2"
- python: "3.12"
django: "3.2"
- python: "3.11"
django: "4.0"
- python: "3.12"
django: "4.0"
- python: "3.8"
django: "5.0"
- python: "3.9"
django: "5.0"
database_url:
- postgres://runner:password@localhost/project
- mysql://root:[email protected]/project
- 'sqlite:///:memory:'

services:
postgres:
image: postgres:12
image: postgres
ports:
- 5432:5432
env:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Simple database-backed job queue. Jobs are defined in your settings, and are pro
Asynchronous tasks are run via a *job queue*. This system is designed to support multi-step job workflows.

Supported and tested against:
- Django 3.2, 4.0, 4.1, 4.2
- Python 3.8, 3.9, 3.10, 3.11
- Django 3.2, 4.0, 4.1, 4.2, 5.0
- Python 3.8, 3.9, 3.10, 3.11, 3.12

## Getting Started

Expand Down
18 changes: 14 additions & 4 deletions django_dbq/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
from io import StringIO


try:
utc = timezone.utc
except AttributeError:
from datetime import timezone as datetime_timezone

utc = datetime_timezone.utc


def test_task(job=None):
pass # pragma: no cover

Expand Down Expand Up @@ -189,7 +197,7 @@ def test_get_next_ready_job(self):
Job.objects.create(name="testjob", state=Job.STATES.READY)
Job.objects.create(name="testjob", state=Job.STATES.PROCESSING)
expected = Job.objects.create(name="testjob", state=Job.STATES.READY)
expected.created = datetime.now() - timedelta(minutes=1)
expected.created = timezone.now() - timedelta(minutes=1)
expected.save()

self.assertEqual(Job.objects.get_ready_or_none("default"), expected)
Expand Down Expand Up @@ -231,7 +239,9 @@ def test_gets_jobs_in_priority_and_date_order(self):

def test_ignores_jobs_until_run_after_is_in_the_past(self):
job_1 = Job.objects.create(name="testjob")
job_2 = Job.objects.create(name="testjob", run_after=datetime(2021, 11, 4, 8))
job_2 = Job.objects.create(
name="testjob", run_after=datetime(2021, 11, 4, 8, tzinfo=utc)
)

with freezegun.freeze_time(datetime(2021, 11, 4, 7)):
self.assertEqual(
Expand All @@ -256,7 +266,7 @@ def test_get_next_ready_job_created(self):
Job.objects.create(name="testjob", state=Job.STATES.NEW)
Job.objects.create(name="testjob", state=Job.STATES.PROCESSING)
expected = Job.objects.create(name="testjob", state=Job.STATES.NEW)
expected.created = datetime.now() - timedelta(minutes=1)
expected.created = timezone.now() - timedelta(minutes=1)
expected.save()

self.assertEqual(Job.objects.get_ready_or_none("default"), expected)
Expand Down Expand Up @@ -336,7 +346,7 @@ def test_failure_hook(self):
@override_settings(JOBS={"testjob": {"tasks": ["a"]}})
class DeleteOldJobsTestCase(TestCase):
def test_delete_old_jobs(self):
two_days_ago = datetime.utcnow() - timedelta(days=2)
two_days_ago = timezone.now() - timedelta(days=2)

j1 = Job.objects.create(name="testjob", state=Job.STATES.COMPLETE)
j1.created = two_days_ago
Expand Down
2 changes: 2 additions & 0 deletions testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
"root": {"handlers": ["console"], "level": "INFO",},
"loggers": {"django_dbq": {"level": "CRITICAL", "propagate": True,},},
}

USE_TZ = True
Loading