Skip to content

Commit fb8f6fe

Browse files
authored
Merge pull request #127 from cloudblue/bump/LITE-27076
LITE-27076 Added support for Django 4.2
2 parents a054973 + 52724ae commit fb8f6fe

File tree

7 files changed

+201
-241
lines changed

7 files changed

+201
-241
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
- name: Testing
3838
run: |
3939
poetry run pytest
40-
build_3_10_django_4_0:
41-
name: Build on Python 3.10 django 4.0
40+
build_3_11_django_4_2:
41+
name: Build on Python 3.11 django 4.2
4242
runs-on: ubuntu-latest
4343
strategy:
4444
matrix:
45-
python-version: ['3.10']
45+
python-version: ['3.11']
4646
steps:
4747
- name: Checkout
4848
uses: actions/checkout@v3
@@ -57,7 +57,7 @@ jobs:
5757
python -m pip install --upgrade pip
5858
pip install poetry
5959
poetry install
60-
poetry run pip install django==4.0.*
60+
poetry run pip install django==4.2.*
6161
- name: Linting
6262
run: |
6363
poetry run flake8
@@ -93,7 +93,7 @@ jobs:
9393
poetry run pytest
9494
sonar:
9595
name: Sonar Checks
96-
needs: [build_3_8_9_10_11_django_3_2, build_3_10_django_4_0, build_3_10_django_4_1]
96+
needs: [build_3_8_9_10_11_django_3_2, build_3_11_django_4_2, build_3_10_django_4_1]
9797
runs-on: ubuntu-latest
9898
steps:
9999
- name: Checkout
@@ -109,7 +109,7 @@ jobs:
109109
python -m pip install --upgrade pip
110110
pip install poetry
111111
poetry install
112-
poetry run pip install django==4.0.*
112+
poetry run pip install django==4.2.*
113113
- name: Testing
114114
run: |
115115
poetry run pytest

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Django CQRS
22
===========
33
![pyversions](https://img.shields.io/pypi/pyversions/django-cqrs.svg)
4-
[![PyPi Status](https://img.shields.io/pypi/v/django-cqrs.svg)](https://pypi.org/project/django-cqrs/)
4+
![PyPI](https://img.shields.io/pypi/v/django-cqrs)
55
[![Docs](https://readthedocs.org/projects/django-cqrs/badge/?version=latest)](https://readthedocs.org/projects/django-cqrs)
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=django-cqrs&metric=coverage)](https://sonarcloud.io/dashboard?id=django-cqrs)
7-
[![Build Status](https://travis-ci.org/cloudblue/django-cqrs.svg?branch=master)](https://travis-ci.org/cloudblue/django-cqrs)
7+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/cloudblue/django-cqrs/build.yml)
88
[![PyPI status](https://img.shields.io/pypi/status/django-cqrs.svg)](https://pypi.python.org/pypi/django-cqrs/)
99
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=django-cqrs&metric=alert_status)](https://sonarcloud.io/dashboard?id=django-cqrs)
1010
[![PyPI Downloads](https://img.shields.io/pypi/dm/django-cqrs)](https://pypi.org/project/django-cqrs/)
11+
![GitHub](https://img.shields.io/github/license/cloudblue/django-cqrs)
1112

1213
`django-cqrs` is an Django application, that implements CQRS data synchronisation between several Django microservices.
1314

poetry.lock

Lines changed: 171 additions & 220 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ classifiers = [
1515
'Framework :: Django :: 3.2',
1616
'Framework :: Django :: 4.0',
1717
'Framework :: Django :: 4.1',
18+
'Framework :: Django :: 4.2',
1819
'Intended Audience :: Developers',
1920
'License :: OSI Approved :: Apache Software License',
2021
'Operating System :: Unix',
@@ -45,11 +46,10 @@ python-dateutil = ">=2.4"
4546
watchfiles = "^0.18.1"
4647

4748
[tool.poetry.group.test.dependencies]
48-
pytest = ">=6.1.2,<8"
49+
pytest = ">=7.2.0,<8"
4950
pytest-cov = ">=2.10.1,<5"
5051
pytest-mock = "^3.3.1"
5152
pytest-django = ">=4.4.0"
52-
pytest-pythonpath = { version = "^0.7.4", python = "<3.8" }
5353
pytest-randomly = ">=3.12"
5454
pytest-deadfixtures = "^2.2.1"
5555
coverage = {extras = ["toml"], version = ">=5.3,<7"}
@@ -86,7 +86,6 @@ python_files = "test_*.py"
8686
DJANGO_SETTINGS_MODULE = "tests.dj.settings"
8787
django_find_project = false
8888
pythonpath = [".", "src"]
89-
python_paths = ["."]
9089

9190
[tool.coverage.xml]
9291
output = "tests/reports/coverage.xml"
@@ -102,3 +101,7 @@ use_parentheses = true
102101
include_trailing_comma = true
103102
line_length = 100
104103
lines_after_imports = 2
104+
105+
[build-system]
106+
requires = ["poetry-core>=1.0.0"]
107+
build-backend = "poetry.core.masonry.api"

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Copyright © 2023 Ingram Micro Inc. All rights reserved.
2+
13
from copy import deepcopy
24

5+
import django
36
import pytest
47

58

@@ -14,3 +17,8 @@ def restore_cqrs_settings(settings):
1417
settings.CQRS = deepcopy(settings.CQRS)
1518

1619
yield
20+
21+
22+
@pytest.fixture()
23+
def django_v_trans_q_count_sup():
24+
return 2 if django.get_version() >= '4.2' else 0

tests/test_controller.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ def change_data(*args, **kwargs):
6363
assert payload.previous_data == {'previous_key': 'initial previous'}
6464

6565

66-
@pytest.mark.django_db(transaction=True)
67-
def test_route_signal_to_replica_model_with_db(django_assert_num_queries):
68-
query_counter = 0 if settings.DB_ENGINE == 'postgres' else 1
69-
with django_assert_num_queries(query_counter):
70-
route_signal_to_replica_model(SignalType.SAVE, 'lock', {})
71-
72-
7366
@pytest.mark.django_db(transaction=True)
7467
def test_route_signal_to_replica_model_integrity_error(caplog):
7568
instance_data = {

tests/test_master/test_mixin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,21 @@ def test_serialization_no_related_instance(mocker):
387387

388388

389389
@pytest.mark.django_db(transaction=True)
390-
def test_save_serialization(mocker, django_assert_num_queries):
390+
def test_save_serialization(mocker, django_assert_num_queries, django_v_trans_q_count_sup):
391391
publisher_mock = mocker.patch('dj_cqrs.controller.producer.produce')
392392

393+
# < Django 4.2
393394
# 0 - Transaction start (SQLite only)
394395
# 1 - Publisher
395396
# 2 - Author
396397
# 3-4 - Books
397398
# 5-6 - Serialization with prefetch_related
398-
query_counter = 7 if settings.DB_ENGINE == 'sqlite' else 6
399+
query_counter = 6 + django_v_trans_q_count_sup
400+
if settings.DB_ENGINE == 'sqlite' and django_v_trans_q_count_sup == 0:
401+
query_counter = 7
402+
399403
with django_assert_num_queries(query_counter):
400-
with transaction.atomic():
404+
with transaction.atomic(savepoint=False):
401405
publisher = models.Publisher.objects.create(id=1, name='publisher')
402406
author = models.Author.objects.create(id=1, name='author', publisher=publisher)
403407
for index in range(1, 3):

0 commit comments

Comments
 (0)