Skip to content

Commit

Permalink
feat: add python 3.11 support (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
edx-requirements-bot authored Apr 11, 2024
1 parent 8cc090e commit 9fe0ae9
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 105 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Python CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches:
- '**'
- '**'


jobs:
Expand All @@ -15,30 +15,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: ["quality", "docs", "django32", "django42"]
python-version: ['3.8', '3.11']
toxenv: ["django42", "quality", "docs"]

steps:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: true
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt

- name: Install Dependencies
run: pip install -r requirements/ci.txt

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

- name: Run coverage
if: matrix.python-version == '3.8' && matrix.toxenv == 'django42'
uses: codecov/codecov-action@v3
with:
flags: unittests
fail_ci_if_error: false
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Change Log
Unreleased
----------

[9.8.0] - 2024-04-11

Added
~~~~~
* Added support for Python 3.11

[9.7.0] - 2024-04-04
--------------------
Added
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.7.0"
__version__ = "9.8.0"
2 changes: 1 addition & 1 deletion openedx_events/content_authoring/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class LibraryBlockData:
@attr.s(frozen=True)
class ContentObjectData:
"""
Data about changed content object
Data about changed content object.
Arguments:
object_id (str): identifier of the Content object. This represents the id of the course or library block
Expand Down
17 changes: 17 additions & 0 deletions openedx_events/event_bus/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""

import copy
import sys
import warnings
from contextlib import contextmanager
from unittest import TestCase

import pytest
from django.test import override_settings

from openedx_events.data import EventsMetadata
Expand Down Expand Up @@ -83,6 +85,7 @@ def test_missing_attribute(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info > (3, 9), reason="Python 3.8.x required") # Temporary until 3.8 is dropped
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable(self):
with assert_warnings([
Expand All @@ -96,6 +99,20 @@ def test_bad_args_for_callable(self):
)
assert loaded == {'def': 'ault'}

@pytest.mark.skipif(sys.version_info < (3, 9), reason="Python 3.11.x required") # Temporary until 3.8 is dropped
@override_settings(EB_LOAD_PATH='builtins.dict')
def test_bad_args_for_callable(self):
with assert_warnings([
"Failed to load <class 'dict'> from setting EB_LOAD_PATH: "
"TypeError('dict() argument after * must be an iterable, not int'); "
"component will be inactive"
]):
loaded = _try_load(
setting_name="EB_LOAD_PATH", args=(1), kwargs={'2': 3},
expected_class=dict, default={'def': 'ault'},
)
assert loaded == {'def': 'ault'}


class TestProducer(TestCase):

Expand Down
14 changes: 6 additions & 8 deletions openedx_events/tests/test_producer_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ def test_enabled_disabled_events(self, mock_producer):
XBLOCK_PUBLISHED.send_event(xblock_info=self.xblock_info)
mock_send.send.assert_called()
mock_send.send.call_count = 2
expected_call_args = [
{'topic': 'enabled_topic_a', 'event_key_field': 'xblock_info.usage_key'},
{'topic': 'enabled_topic_b', 'event_key_field': 'xblock_info.usage_key'}
]

# check that call_args_list only consists of enabled topics.
call_args = mock_send.send.call_args_list[0][1]
self.assertDictContainsSubset(
{'topic': 'enabled_topic_a', 'event_key_field': 'xblock_info.usage_key'},
call_args
)
self.assertEqual(call_args, {**call_args, **expected_call_args[0]})
call_args = mock_send.send.call_args_list[1][1]
self.assertDictContainsSubset(
{'topic': 'enabled_topic_b', 'event_key_field': 'xblock_info.usage_key'},
call_args
)
self.assertEqual(call_args, {**call_args, **expected_call_args[1]})

@patch("openedx_events.apps.logger")
@patch('openedx_events.apps.get_producer')
Expand Down
6 changes: 4 additions & 2 deletions openedx_events/tests/test_tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ def test_generate_signal_metadata(self, datetime_mock, socket_mock, events_packa
}

metadata = self.public_signal.generate_signal_metadata()
metadata_as_dict = attr.asdict(metadata)

self.assertDictContainsSubset(expected_metadata, attr.asdict(metadata))
self.assertEqual(metadata_as_dict, {**expected_metadata, **metadata_as_dict})
self.assertIsInstance(metadata.id, UUID)

@override_settings(SERVICE_VARIANT="lms")
Expand All @@ -138,8 +139,9 @@ def test_generate_signal_metadata_with_valid_time(self, socket_mock, events_pack
}

metadata = self.public_signal.generate_signal_metadata(time=expected_time)
metadata_as_dict = attr.asdict(metadata)

self.assertDictContainsSubset(expected_metadata, attr.asdict(metadata))
self.assertEqual(metadata_as_dict, {**expected_metadata, **metadata_as_dict})
self.assertIsInstance(metadata.id, UUID)

@ddt.data(
Expand Down
14 changes: 8 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ asgiref==3.8.1
# via django
attrs==23.2.0
# via -r requirements/base.in
backports-zoneinfo==0.2.1
# via django
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# django
cffi==1.16.0
# via pynacl
click==8.1.7
Expand All @@ -25,19 +27,19 @@ django-crum==0.7.9
# via edx-django-utils
django-waffle==4.1.0
# via edx-django-utils
edx-django-utils==5.11.0
edx-django-utils==5.12.0
# via -r requirements/base.in
edx-opaque-keys[django]==2.5.1
# via -r requirements/base.in
fastavro==1.9.4
# via -r requirements/base.in
newrelic==9.7.1
newrelic==9.8.0
# via edx-django-utils
pbr==6.0.0
# via stevedore
psutil==5.9.8
# via edx-django-utils
pycparser==2.21
pycparser==2.22
# via cffi
pymongo==3.13.0
# via edx-opaque-keys
Expand All @@ -49,7 +51,7 @@ stevedore==5.2.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.10.0
typing-extensions==4.11.0
# via
# asgiref
# edx-opaque-keys
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ colorama==0.4.6
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.13.1
filelock==3.13.4
# via
# tox
# virtualenv
Expand Down
3 changes: 3 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
# This should be removed once the issue is fixed with a new astroid release or with a test_generate_avro_schemas.py
# module refactor.
astroid<3.0.0

# Temporary to Support the python 3.11 Upgrade
backports.zoneinfo;python_version<"3.9" # Newer versions have zoneinfo available in the standard library
27 changes: 16 additions & 11 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ astroid==2.15.8
# pylint-celery
attrs==23.2.0
# via -r requirements/quality.txt
backports-zoneinfo==0.2.1
backports-tarfile==1.0.0
# via
# -r requirements/quality.txt
# jaraco-context
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# -c requirements/constraints.txt
# -r requirements/quality.txt
# django
build==1.1.1
build==1.2.1
# via
# -r requirements/pip-tools.txt
# pip-tools
Expand Down Expand Up @@ -106,7 +111,7 @@ docutils==0.20.1
# via
# -r requirements/quality.txt
# readme-renderer
edx-django-utils==5.11.0
edx-django-utils==5.12.0
# via -r requirements/quality.txt
edx-lint==5.3.6
# via -r requirements/quality.txt
Expand All @@ -118,7 +123,7 @@ exceptiongroup==1.2.0
# pytest
fastavro==1.9.4
# via -r requirements/quality.txt
filelock==3.13.1
filelock==3.13.4
# via
# -r requirements/ci.txt
# tox
Expand Down Expand Up @@ -147,11 +152,11 @@ isort==5.13.2
# via
# -r requirements/quality.txt
# pylint
jaraco-classes==3.3.1
jaraco-classes==3.4.0
# via
# -r requirements/quality.txt
# keyring
jaraco-context==4.3.0
jaraco-context==5.3.0
# via
# -r requirements/quality.txt
# keyring
Expand All @@ -169,7 +174,7 @@ jinja2==3.1.3
# -r requirements/quality.txt
# code-annotations
# diff-cover
keyring==25.0.0
keyring==25.1.0
# via
# -r requirements/quality.txt
# twine
Expand Down Expand Up @@ -198,11 +203,11 @@ more-itertools==10.2.0
# -r requirements/quality.txt
# jaraco-classes
# jaraco-functools
newrelic==9.7.1
newrelic==9.8.0
# via
# -r requirements/quality.txt
# edx-django-utils
nh3==0.2.15
nh3==0.2.17
# via
# -r requirements/quality.txt
# readme-renderer
Expand Down Expand Up @@ -245,7 +250,7 @@ psutil==5.9.8
# edx-django-utils
pycodestyle==2.11.1
# via -r requirements/quality.txt
pycparser==2.21
pycparser==2.22
# via
# -r requirements/quality.txt
# cffi
Expand Down Expand Up @@ -379,7 +384,7 @@ tox==4.14.2
# via -r requirements/ci.txt
twine==5.0.0
# via -r requirements/quality.txt
typing-extensions==4.10.0
typing-extensions==4.11.0
# via
# -r requirements/quality.txt
# asgiref
Expand Down
Loading

0 comments on commit 9fe0ae9

Please sign in to comment.