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

Django upgrade 4.2 #321

Merged
merged 4 commits into from
Jul 5, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [docs, quality, django32]
toxenv: [docs, quality, django32, django42]

steps:
- uses: actions/checkout@v1
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions edx_django_utils/cache/tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Tests for the RequestCacheMiddleware.
"""
from unittest.mock import MagicMock
from unittest.mock import MagicMock, Mock

from django.test import RequestFactory, TestCase

Expand All @@ -17,7 +17,8 @@ class TestRequestCacheMiddleware(TestCase): # pylint: disable=missing-class-doc

def setUp(self):
super().setUp()
self.middleware = middleware.RequestCacheMiddleware()
self.mock_response = Mock()
self.middleware = middleware.RequestCacheMiddleware(self.mock_response)
self.request = RequestFactory().get('/')

self.request_cache = RequestCache()
Expand Down Expand Up @@ -50,7 +51,8 @@ class TestTieredCacheMiddleware(TestCase): # pylint: disable=missing-class-docs

def setUp(self):
super().setUp()
self.middleware = middleware.TieredCacheMiddleware()
self.mock_response = Mock()
self.middleware = middleware.TieredCacheMiddleware(self.mock_response)
self.request = RequestFactory().get('/')
self.request.user = self._mock_user(is_staff=True)

Expand Down
8 changes: 5 additions & 3 deletions edx_django_utils/monitoring/tests/test_custom_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Note: See test_middleware.py for the rest of the middleware tests.
"""
from unittest.mock import call, patch
from unittest.mock import Mock, call, patch

import ddt
from django.test import TestCase
Expand Down Expand Up @@ -32,6 +32,7 @@ class TestCustomMonitoringMiddleware(TestCase):
"""
def setUp(self):
super().setUp()
self.mock_response = Mock()
RequestCache.clear_all_namespaces()

@patch('newrelic.agent')
Expand Down Expand Up @@ -62,7 +63,7 @@ def test_accumulate_and_increment(
]

# fake a response to trigger attributes reporting
middleware_method = getattr(cached_monitoring_middleware_class(), middleware_method_name)
middleware_method = getattr(cached_monitoring_middleware_class(self.mock_response), middleware_method_name)
middleware_method(
'fake request',
'fake response',
Expand Down Expand Up @@ -101,8 +102,9 @@ def test_accumulate_with_illegal_value(
call('error_adding_accumulated_metric', 'name=hello, new_value=10, cached_value=None'),
]

self.mock_response = Mock()
# fake a response to trigger metrics reporting
cached_monitoring_middleware_class().process_response(
cached_monitoring_middleware_class(self.mock_response).process_response(
'fake request',
'fake response',
)
Expand Down
6 changes: 4 additions & 2 deletions edx_django_utils/monitoring/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TestMonitoringMemoryMiddleware(TestCase):
@override_switch('edx_django_utils.monitoring.enable_memory_middleware', False)
@patch('edx_django_utils.monitoring.internal.middleware.log')
def test_memory_monitoring_when_disabled(self, mock_logger):
MonitoringMemoryMiddleware().process_response(
mock_response = Mock()
MonitoringMemoryMiddleware(mock_response).process_response(
'fake request',
'fake response',
)
Expand All @@ -37,7 +38,8 @@ def test_memory_monitoring_when_disabled(self, mock_logger):
@patch('edx_django_utils.monitoring.internal.middleware.log')
def test_memory_monitoring_when_enabled(self, mock_logger):
request = RequestFactory().get('/')
MonitoringMemoryMiddleware().process_response(
mock_response = Mock()
MonitoringMemoryMiddleware(mock_response).process_response(
request,
'fake response',
)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def is_requirement(line):
'Development Status :: 3 - Alpha',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38-django{32}
envlist = py38-django{32, 42}

[doc8]
ignore = D000, D001
Expand Down Expand Up @@ -38,6 +38,7 @@ norecursedirs = .* docs requirements
[testenv]
deps =
django32: Django>=3.2,<4.0
django42: Django>=4.2,<4.3
-r{toxinidir}/requirements/test.txt
commands =
python -Wd -m pytest {posargs}
Expand Down