From 49ba7422d4b489f3c6916962d3626eb675fd1b6c Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 19 Feb 2024 12:00:00 +0500 Subject: [PATCH 1/6] chore: update python version to support tests with 3.11, 3.12 --- .github/workflows/ci.yml | 6 +++--- edx_event_bus_redis/__init__.py | 2 +- edx_event_bus_redis/internal/tests/test_message.py | 2 +- setup.py | 4 +++- tox.ini | 5 ++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80cc1d5..9ab23d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,8 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - python-version: ['3.8'] - toxenv: [quality, docs, pii_check, django32, django40] + python-version: ['3.8', '3.11', '3.12'] + toxenv: [quality, docs, pii_check, django42] steps: - uses: actions/checkout@v3 @@ -37,7 +37,7 @@ jobs: run: tox - name: Run coverage - if: matrix.python-version == '3.8' && matrix.toxenv == 'django32' + if: matrix.python-version == '3.8' && matrix.toxenv == 'django42' uses: codecov/codecov-action@v3 with: flags: unittests diff --git a/edx_event_bus_redis/__init__.py b/edx_event_bus_redis/__init__.py index dc14858..da95f68 100644 --- a/edx_event_bus_redis/__init__.py +++ b/edx_event_bus_redis/__init__.py @@ -5,6 +5,6 @@ from edx_event_bus_redis.internal.consumer import RedisEventConsumer from edx_event_bus_redis.internal.producer import create_producer -__version__ = '0.3.2' +__version__ = '0.4.0' default_app_config = 'edx_event_bus_redis.apps.EdxEventBusRedisConfig' # pylint: disable=invalid-name diff --git a/edx_event_bus_redis/internal/tests/test_message.py b/edx_event_bus_redis/internal/tests/test_message.py index 933cf66..abe21d2 100644 --- a/edx_event_bus_redis/internal/tests/test_message.py +++ b/edx_event_bus_redis/internal/tests/test_message.py @@ -74,7 +74,7 @@ def test_no_event_data(self): assert excinfo.value.args == ( "Error determining metadata from message headers: " - "__init__() missing 1 required positional argument: 'event_type'", + "EventsMetadata.__init__() missing 1 required positional argument: 'event_type'", ) def test_bad_msg(self): diff --git a/setup.py b/setup.py index fbd52a8..47aab26 100644 --- a/setup.py +++ b/setup.py @@ -154,11 +154,13 @@ def is_requirement(line): classifiers=[ 'Development Status :: 3 - Alpha', 'Framework :: Django', - 'Framework :: Django :: 3.2', + 'Framework :: Django :: 4.2', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', 'Natural Language :: English', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], ) diff --git a/tox.ini b/tox.ini index a961bd6..433fd53 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38-django{32,40} +envlist = py{38,311,312}-django{42} [pycodestyle] exclude = .git,.tox,migrations @@ -32,8 +32,7 @@ norecursedirs = .* docs requirements site-packages [testenv] deps = - django32: Django>=3.2,<4.0 - django40: Django>=4.0,<4.1 + django42: Django>=4.2,<5.0 -r{toxinidir}/requirements/test.txt commands = python manage.py check From 65fc28ad8ed436484bc49f0fda924d9b0331284e Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 19 Feb 2024 19:21:34 +0500 Subject: [PATCH 2/6] chore: fix test case --- edx_event_bus_redis/internal/tests/test_message.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/edx_event_bus_redis/internal/tests/test_message.py b/edx_event_bus_redis/internal/tests/test_message.py index abe21d2..35a9b0d 100644 --- a/edx_event_bus_redis/internal/tests/test_message.py +++ b/edx_event_bus_redis/internal/tests/test_message.py @@ -68,13 +68,18 @@ def test_no_type(self): ) def test_no_event_data(self): - msg = (b'1', {b'id': b'629f9892-c258-11ed-8dac-1c83413013cb', b'event_data': self.event_data_bytes}) + msg = ( + b'1', + { + b'id': b'629f9892-c258-11ed-8dac-1c83413013cb', + b'event_data': self.event_data_bytes, + } + ) with pytest.raises(UnusableMessageError) as excinfo: RedisMessage.parse(msg, topic='some-local-topic') - + #import pdb; pdb.set_trace() assert excinfo.value.args == ( - "Error determining metadata from message headers: " - "EventsMetadata.__init__() missing 1 required positional argument: 'event_type'", + "Error determining metadata from message headers: EventsMetadata.__init__() missing 1 required positional argument: 'event_type'", ) def test_bad_msg(self): From ff7c34c2531b963ddbcd96cdc6a076fdea3b0526 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 19 Feb 2024 19:53:29 +0500 Subject: [PATCH 3/6] chore: fix tests for 3.11 and 3.12 --- edx_event_bus_redis/internal/tests/test_message.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/edx_event_bus_redis/internal/tests/test_message.py b/edx_event_bus_redis/internal/tests/test_message.py index 35a9b0d..4def225 100644 --- a/edx_event_bus_redis/internal/tests/test_message.py +++ b/edx_event_bus_redis/internal/tests/test_message.py @@ -4,7 +4,7 @@ from datetime import datetime, timezone from uuid import UUID - +import re import ddt import pytest from django.test import TestCase @@ -77,10 +77,10 @@ def test_no_event_data(self): ) with pytest.raises(UnusableMessageError) as excinfo: RedisMessage.parse(msg, topic='some-local-topic') - #import pdb; pdb.set_trace() - assert excinfo.value.args == ( - "Error determining metadata from message headers: EventsMetadata.__init__() missing 1 required positional argument: 'event_type'", + expected_error_pattern = re.compile( + r"Error determining metadata from message headers: .*__init__\(\) missing 1 required positional argument: 'event_type'" ) + assert expected_error_pattern.search(str(excinfo.value)) is not None def test_bad_msg(self): """ From 7d5e6a0933ee29cbb3332940cf09954cc71da428 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Mon, 19 Feb 2024 19:58:09 +0500 Subject: [PATCH 4/6] chore: fix tests --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 47aab26..c84d176 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def check_name_consistent(package): if seen_spelling is None: by_canonical_name[canonical] = package elif seen_spelling != package: - raise Exception( # pylint: disable=broad-exception-raised + raise Exception( f'Encountered both "{seen_spelling}" and "{package}" in requirements ' 'and constraints files; please use just one or the other.' ) From f89137f76d06f5a19f36e579d0a544d8fc2c0c66 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Tue, 20 Feb 2024 15:21:10 +0500 Subject: [PATCH 5/6] chore: fix test cases --- edx_event_bus_redis/internal/tests/test_message.py | 10 ++++++---- setup.py | 2 +- tox.ini | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/edx_event_bus_redis/internal/tests/test_message.py b/edx_event_bus_redis/internal/tests/test_message.py index 4def225..4b155a7 100644 --- a/edx_event_bus_redis/internal/tests/test_message.py +++ b/edx_event_bus_redis/internal/tests/test_message.py @@ -2,9 +2,10 @@ Tests for message module. """ +import re from datetime import datetime, timezone from uuid import UUID -import re + import ddt import pytest from django.test import TestCase @@ -69,16 +70,17 @@ def test_no_type(self): def test_no_event_data(self): msg = ( - b'1', + b'1', { - b'id': b'629f9892-c258-11ed-8dac-1c83413013cb', + b'id': b'629f9892-c258-11ed-8dac-1c83413013cb', b'event_data': self.event_data_bytes, } ) with pytest.raises(UnusableMessageError) as excinfo: RedisMessage.parse(msg, topic='some-local-topic') expected_error_pattern = re.compile( - r"Error determining metadata from message headers: .*__init__\(\) missing 1 required positional argument: 'event_type'" + r"Error determining metadata from message headers: .*__init__\(\) " + r"missing 1 required positional argument: 'event_type'" ) assert expected_error_pattern.search(str(excinfo.value)) is not None diff --git a/setup.py b/setup.py index c84d176..47aab26 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def check_name_consistent(package): if seen_spelling is None: by_canonical_name[canonical] = package elif seen_spelling != package: - raise Exception( + raise Exception( # pylint: disable=broad-exception-raised f'Encountered both "{seen_spelling}" and "{package}" in requirements ' 'and constraints files; please use just one or the other.' ) diff --git a/tox.ini b/tox.ini index 433fd53..d63e5ab 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,7 @@ norecursedirs = .* docs requirements site-packages [testenv] deps = django42: Django>=4.2,<5.0 + setuptools -r{toxinidir}/requirements/test.txt commands = python manage.py check @@ -63,6 +64,7 @@ allowlist_externals = rm touch deps = + setuptools -r{toxinidir}/requirements/quality.txt commands = touch tests/__init__.py From 6318e8a72fffe5050de9abca553189f39ae77690 Mon Sep 17 00:00:00 2001 From: salman2013 Date: Thu, 22 Feb 2024 17:13:09 +0500 Subject: [PATCH 6/6] chore: remove 3.11 --- .github/workflows/ci.yml | 2 +- setup.py | 1 - tox.ini | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ab23d9..7bdcffc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-20.04] - python-version: ['3.8', '3.11', '3.12'] + python-version: ['3.8', '3.12'] toxenv: [quality, docs, pii_check, django42] steps: diff --git a/setup.py b/setup.py index 47aab26..5f5bbb5 100644 --- a/setup.py +++ b/setup.py @@ -160,7 +160,6 @@ def is_requirement(line): 'Natural Language :: English', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', ], ) diff --git a/tox.ini b/tox.ini index d63e5ab..6e87e4a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{38,311,312}-django{42} +envlist = py{38,312}-django{42} [pycodestyle] exclude = .git,.tox,migrations