Skip to content

Commit

Permalink
Merge pull request #127 from cloudblue/bump/LITE-27076
Browse files Browse the repository at this point in the history
LITE-27076 Added support for Django 4.2
  • Loading branch information
maxipavlovic authored Apr 7, 2023
2 parents a054973 + 52724ae commit fb8f6fe
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 241 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ jobs:
- name: Testing
run: |
poetry run pytest
build_3_10_django_4_0:
name: Build on Python 3.10 django 4.0
build_3_11_django_4_2:
name: Build on Python 3.11 django 4.2
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
python-version: ['3.11']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -57,7 +57,7 @@ jobs:
python -m pip install --upgrade pip
pip install poetry
poetry install
poetry run pip install django==4.0.*
poetry run pip install django==4.2.*
- name: Linting
run: |
poetry run flake8
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
poetry run pytest
sonar:
name: Sonar Checks
needs: [build_3_8_9_10_11_django_3_2, build_3_10_django_4_0, build_3_10_django_4_1]
needs: [build_3_8_9_10_11_django_3_2, build_3_11_django_4_2, build_3_10_django_4_1]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -109,7 +109,7 @@ jobs:
python -m pip install --upgrade pip
pip install poetry
poetry install
poetry run pip install django==4.0.*
poetry run pip install django==4.2.*
- name: Testing
run: |
poetry run pytest
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Django CQRS
===========
![pyversions](https://img.shields.io/pypi/pyversions/django-cqrs.svg)
[![PyPi Status](https://img.shields.io/pypi/v/django-cqrs.svg)](https://pypi.org/project/django-cqrs/)
![PyPI](https://img.shields.io/pypi/v/django-cqrs)
[![Docs](https://readthedocs.org/projects/django-cqrs/badge/?version=latest)](https://readthedocs.org/projects/django-cqrs)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=django-cqrs&metric=coverage)](https://sonarcloud.io/dashboard?id=django-cqrs)
[![Build Status](https://travis-ci.org/cloudblue/django-cqrs.svg?branch=master)](https://travis-ci.org/cloudblue/django-cqrs)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/cloudblue/django-cqrs/build.yml)
[![PyPI status](https://img.shields.io/pypi/status/django-cqrs.svg)](https://pypi.python.org/pypi/django-cqrs/)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=django-cqrs&metric=alert_status)](https://sonarcloud.io/dashboard?id=django-cqrs)
[![PyPI Downloads](https://img.shields.io/pypi/dm/django-cqrs)](https://pypi.org/project/django-cqrs/)
![GitHub](https://img.shields.io/github/license/cloudblue/django-cqrs)

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

Expand Down
391 changes: 171 additions & 220 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ classifiers = [
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: Unix',
Expand Down Expand Up @@ -45,11 +46,10 @@ python-dateutil = ">=2.4"
watchfiles = "^0.18.1"

[tool.poetry.group.test.dependencies]
pytest = ">=6.1.2,<8"
pytest = ">=7.2.0,<8"
pytest-cov = ">=2.10.1,<5"
pytest-mock = "^3.3.1"
pytest-django = ">=4.4.0"
pytest-pythonpath = { version = "^0.7.4", python = "<3.8" }
pytest-randomly = ">=3.12"
pytest-deadfixtures = "^2.2.1"
coverage = {extras = ["toml"], version = ">=5.3,<7"}
Expand Down Expand Up @@ -86,7 +86,6 @@ python_files = "test_*.py"
DJANGO_SETTINGS_MODULE = "tests.dj.settings"
django_find_project = false
pythonpath = [".", "src"]
python_paths = ["."]

[tool.coverage.xml]
output = "tests/reports/coverage.xml"
Expand All @@ -102,3 +101,7 @@ use_parentheses = true
include_trailing_comma = true
line_length = 100
lines_after_imports = 2

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Copyright © 2023 Ingram Micro Inc. All rights reserved.

from copy import deepcopy

import django
import pytest


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

yield


@pytest.fixture()
def django_v_trans_q_count_sup():
return 2 if django.get_version() >= '4.2' else 0
7 changes: 0 additions & 7 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ def change_data(*args, **kwargs):
assert payload.previous_data == {'previous_key': 'initial previous'}


@pytest.mark.django_db(transaction=True)
def test_route_signal_to_replica_model_with_db(django_assert_num_queries):
query_counter = 0 if settings.DB_ENGINE == 'postgres' else 1
with django_assert_num_queries(query_counter):
route_signal_to_replica_model(SignalType.SAVE, 'lock', {})


@pytest.mark.django_db(transaction=True)
def test_route_signal_to_replica_model_integrity_error(caplog):
instance_data = {
Expand Down
10 changes: 7 additions & 3 deletions tests/test_master/test_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,21 @@ def test_serialization_no_related_instance(mocker):


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

# < Django 4.2
# 0 - Transaction start (SQLite only)
# 1 - Publisher
# 2 - Author
# 3-4 - Books
# 5-6 - Serialization with prefetch_related
query_counter = 7 if settings.DB_ENGINE == 'sqlite' else 6
query_counter = 6 + django_v_trans_q_count_sup
if settings.DB_ENGINE == 'sqlite' and django_v_trans_q_count_sup == 0:
query_counter = 7

with django_assert_num_queries(query_counter):
with transaction.atomic():
with transaction.atomic(savepoint=False):
publisher = models.Publisher.objects.create(id=1, name='publisher')
author = models.Author.objects.create(id=1, name='author', publisher=publisher)
for index in range(1, 3):
Expand Down

0 comments on commit fb8f6fe

Please sign in to comment.