From 5e0a692cfd09702e0335f0a1b1bc3f20f1e5900d Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Fri, 21 Jul 2023 06:24:54 +0200 Subject: [PATCH] Update to Django 4.2 --- README.md | 3 + poetry.lock | 70 +- pyproject.toml | 5 +- ...location_empty_change_list_1.snapshot.html | 54 +- src/inventory_project/settings/base.py | 11 - src/inventory_project/tests/conftest.py | 8 +- src/inventory_project/tests/test_admin.py | 63 +- ...dmin_item_auto_group_items_1.snapshot.html | 77 +- ...l_user_create_minimal_item_1.snapshot.html | 472 ++++++++----- ...l_user_create_minimal_item_2.snapshot.html | 666 +++++++++++------- ...l_user_create_minimal_item_1.snapshot.html | 148 ++-- .../tests/test_playwright_admin.py | 35 +- 12 files changed, 921 insertions(+), 691 deletions(-) diff --git a/README.md b/README.md index b6f495a..fbca08c 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,9 @@ Files are separated into: "/src/" and "/development/" * [**dev**](https://github.com/jedie/PyInventory/compare/v0.18.1...main) + * Update to Django 4.2 + * remove django-processinfo + * Bugfix ItemModelAdmin * tbc * [v0.18.1 - 15.06.2023](https://github.com/jedie/PyInventory/compare/v0.18.0...v0.18.1) * Update requirements diff --git a/poetry.lock b/poetry.lock index 8d2ea07..11dc5f5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -384,13 +384,13 @@ files = [ [[package]] name = "click" -version = "8.1.5" +version = "8.1.6" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" files = [ - {file = "click-8.1.5-py3-none-any.whl", hash = "sha256:e576aa487d679441d7d30abb87e1b43d24fc53bffb8758443b1a9e1cee504548"}, - {file = "click-8.1.5.tar.gz", hash = "sha256:4be4b1af8d665c6d942909916d31a213a106800c47d0eeba73d34da3cbc11367"}, + {file = "click-8.1.6-py3-none-any.whl", hash = "sha256:fa244bb30b3b5ee2cae3da8f55c9e5e0c0e86093306301fb418eb9dc40fbded5"}, + {file = "click-8.1.6.tar.gz", hash = "sha256:48ee849951919527a045bfe3bf7baa8a959c423134e1a5b98c05c20ba75a1cbd"}, ] [package.dependencies] @@ -660,13 +660,13 @@ dev = ["attribution (==1.6.2)", "black (==23.3.0)", "flit (==3.8.0)", "mypy (==1 [[package]] name = "distlib" -version = "0.3.6" +version = "0.3.7" description = "Distribution utilities" optional = false python-versions = "*" files = [ - {file = "distlib-0.3.6-py2.py3-none-any.whl", hash = "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e"}, - {file = "distlib-0.3.6.tar.gz", hash = "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46"}, + {file = "distlib-0.3.7-py2.py3-none-any.whl", hash = "sha256:2e24928bc811348f0feb63014e97aaae3037f2cf48712d51ae61df7fd6075057"}, + {file = "distlib-0.3.7.tar.gz", hash = "sha256:9dafe54b34a028eafd95039d5e5d4851a13734540f1331060d31c9916e7147a8"}, ] [[package]] @@ -682,18 +682,18 @@ files = [ [[package]] name = "django" -version = "4.0.10" +version = "4.2.3" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." optional = false python-versions = ">=3.8" files = [ - {file = "Django-4.0.10-py3-none-any.whl", hash = "sha256:4496eb4f65071578b703fdc6e6f29302553c7440e3f77baf4cefa4a4e091fc3d"}, - {file = "Django-4.0.10.tar.gz", hash = "sha256:2c2f73c16b11cb272c6d5e3b063f0d1be06f378d8dc6005fbe8542565db659cc"}, + {file = "Django-4.2.3-py3-none-any.whl", hash = "sha256:f7c7852a5ac5a3da5a8d5b35cc6168f31b605971441798dac845f17ca8028039"}, + {file = "Django-4.2.3.tar.gz", hash = "sha256:45a747e1c5b3d6df1b141b1481e193b033fd1fdbda3ff52677dc81afdaacbaed"}, ] [package.dependencies] -asgiref = ">=3.4.1,<4" -sqlparse = ">=0.2.2" +asgiref = ">=3.6.0,<4" +sqlparse = ">=0.3.1" tzdata = {version = "*", markers = "sys_platform == \"win32\""} [package.extras] @@ -702,13 +702,13 @@ bcrypt = ["bcrypt"] [[package]] name = "django-admin-sortable2" -version = "2.1.8" +version = "2.1.9" description = "Generic drag-and-drop sorting for the List, the Stacked- and the Tabular-Inlines Views in the Django Admin" optional = false python-versions = "*" files = [ - {file = "django-admin-sortable2-2.1.8.tar.gz", hash = "sha256:6933a9bba9dbedc4a106bb488e4b8a1fb85cbe0459fb46504fe602d65dbfd3e9"}, - {file = "django_admin_sortable2-2.1.8-py3-none-any.whl", hash = "sha256:aeb75152c2ed222cf0894e96c449bb2b64eb629f0494b4b203c23e0b36ca2349"}, + {file = "django-admin-sortable2-2.1.9.tar.gz", hash = "sha256:bf036785c598685a0019eb08340b88fe6ca74bd178033e2290e6c41b62fa4bf1"}, + {file = "django_admin_sortable2-2.1.9-py3-none-any.whl", hash = "sha256:6de19689cb2f131d256ce19d2fd148728d551943d8463b1d81f6334adfa0b6fc"}, ] [package.dependencies] @@ -810,20 +810,6 @@ django = ">=3.2" [package.extras] tests = ["coverage"] -[[package]] -name = "django-processinfo" -version = "1.1.0" -description = "Django application to collect information about the running server processes." -optional = false -python-versions = ">=3.7,<4.0.0" -files = [ - {file = "django-processinfo-1.1.0.tar.gz", hash = "sha256:e5d883c2bd4d3a197357bb381a4c19165b5c9ff9a852f96b0dd1ccfd98e2e4a2"}, - {file = "django_processinfo-1.1.0-py3-none-any.whl", hash = "sha256:c7d1fe2203655925294c860878509fe2a6eb1a5390a170c848023e4619b903da"}, -] - -[package.dependencies] -Django = "*" - [[package]] name = "django-reversion" version = "5.0.4" @@ -1191,17 +1177,17 @@ test = ["objgraph", "psutil"] [[package]] name = "gunicorn" -version = "20.1.0" +version = "21.2.0" description = "WSGI HTTP Server for UNIX" optional = false python-versions = ">=3.5" files = [ - {file = "gunicorn-20.1.0-py3-none-any.whl", hash = "sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e"}, - {file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"}, + {file = "gunicorn-21.2.0-py3-none-any.whl", hash = "sha256:3213aa5e8c24949e792bcacfc176fef362e7aac80b76c56f6b5122bf350722f0"}, + {file = "gunicorn-21.2.0.tar.gz", hash = "sha256:88ec8bff1d634f98e61b9f65bc4bf3cd918a90806c6f5c48bc5603849ec81033"}, ] [package.dependencies] -setuptools = ">=3.0" +packaging = "*" [package.extras] eventlet = ["eventlet (>=0.24.1)"] @@ -1752,13 +1738,13 @@ testing = ["pytest", "pytest-cov"] [[package]] name = "platformdirs" -version = "3.8.1" +version = "3.9.1" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-3.8.1-py3-none-any.whl", hash = "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c"}, - {file = "platformdirs-3.8.1.tar.gz", hash = "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528"}, + {file = "platformdirs-3.9.1-py3-none-any.whl", hash = "sha256:ad8291ae0ae5072f66c16945166cb11c63394c7a3ad1b1bc9828ca3162da8c2f"}, + {file = "platformdirs-3.9.1.tar.gz", hash = "sha256:1b42b450ad933e981d56e59f1b97495428c9bd60698baab9f3eb3d00d5822421"}, ] [package.extras] @@ -2763,13 +2749,13 @@ files = [ [[package]] name = "urllib3" -version = "2.0.3" +version = "2.0.4" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.7" files = [ - {file = "urllib3-2.0.3-py3-none-any.whl", hash = "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1"}, - {file = "urllib3-2.0.3.tar.gz", hash = "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825"}, + {file = "urllib3-2.0.4-py3-none-any.whl", hash = "sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4"}, + {file = "urllib3-2.0.4.tar.gz", hash = "sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"}, ] [package.extras] @@ -2780,13 +2766,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.24.0" +version = "20.24.1" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.0-py3-none-any.whl", hash = "sha256:18d1b37fc75cc2670625702d76849a91ebd383768b4e91382a8d51be3246049e"}, - {file = "virtualenv-20.24.0.tar.gz", hash = "sha256:e2a7cef9da880d693b933db7654367754f14e20650dc60e8ee7385571f8593a3"}, + {file = "virtualenv-20.24.1-py3-none-any.whl", hash = "sha256:01aacf8decd346cf9a865ae85c0cdc7f64c8caa07ff0d8b1dfc1733d10677442"}, + {file = "virtualenv-20.24.1.tar.gz", hash = "sha256:2ef6a237c31629da6442b0bcaa3999748108c7166318d1f55cc9f8d7294e97bd"}, ] [package.dependencies] @@ -2883,4 +2869,4 @@ psycopg2-source = ["psycopg2"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0.0" -content-hash = "741fee43ced106c7d53820902dc418abc9e4c3b1ad3c1007a5f38f9477e17e2a" +content-hash = "c1cc7b68e0d4fdc3ebfb977fd4dc524e5b04cf86e744a9c8ddaa2cefa6b9d9a5" diff --git a/pyproject.toml b/pyproject.toml index 78935f6..fd90ed7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,12 +42,9 @@ readme = 'README.md' [tool.poetry.dependencies] python = ">=3.9,<4.0.0" # Stay with 3.9 until YunoHost used >=Debian 11 (Bullseye) - -django = "<4.1" # FIXME: https://github.com/jedie/django-processinfo/issues/19 - +django = "*" colorlog = "*" # https://github.com/borntyping/python-colorlog gunicorn = "*" # https://github.com/benoimyproject.wsgitc/gunicorn -django-processinfo = "*" # https://github.com/jedie/django-processinfo/ django-debug-toolbar = "*" # http://django-debug-toolbar.readthedocs.io/en/stable/changes.html django-import-export = "*" # https://github.com/django-import-export/django-import-export django-dbbackup = "*" # https://github.com/django-dbbackup/django-dbbackup diff --git a/src/inventory/tests/test_admin_location_empty_change_list_1.snapshot.html b/src/inventory/tests/test_admin_location_empty_change_list_1.snapshot.html index 5640220..9252d45 100644 --- a/src/inventory/tests/test_admin_location_empty_change_list_1.snapshot.html +++ b/src/inventory/tests/test_admin_location_empty_change_list_1.snapshot.html @@ -34,7 +34,7 @@ - + @@ -50,31 +50,33 @@

Filter

-

- By Limit tree depth -

- +
+ + By Limit tree depth + + +
diff --git a/src/inventory_project/settings/base.py b/src/inventory_project/settings/base.py index e4ef076..7986833 100644 --- a/src/inventory_project/settings/base.py +++ b/src/inventory_project/settings/base.py @@ -81,7 +81,6 @@ INSTALLED_APPS = [ 'tagulous', # https://github.com/radiac/django-tagulous 'adminsortable2', # https://github.com/jrief/django-admin-sortable2 'axes', # https://github.com/jazzband/django-axes - 'django_processinfo', # https://github.com/jedie/django-processinfo/ # https://github.com/jedie/django-tools/tree/master/django_tools/serve_media_app 'django_tools.serve_media_app.apps.UserMediaFilesConfig', @@ -102,8 +101,6 @@ AUTHENTICATION_BACKENDS = [ ] MIDDLEWARE = [ - 'django_processinfo.middlewares.ProcessInfoMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', @@ -190,14 +187,6 @@ STATIC_ROOT = str(__Path(BASE_PATH, 'static')) MEDIA_URL = '/media/' MEDIA_ROOT = str(__Path(BASE_PATH, 'media')) -# _____________________________________________________________________________ -# django-processinfo - -from django_processinfo import app_settings as PROCESSINFO # noqa - - -PROCESSINFO.ADD_INFO = False # Don't add info in HTML page - # _____________________________________________________________________________ # Django-dbbackup diff --git a/src/inventory_project/tests/conftest.py b/src/inventory_project/tests/conftest.py index 6cfe587..ffa0c5d 100644 --- a/src/inventory_project/tests/conftest.py +++ b/src/inventory_project/tests/conftest.py @@ -11,7 +11,13 @@ os.environ.setdefault('DJANGO_ALLOW_ASYNC_UNSAFE', '1') @pytest.fixture(scope='session') def browser_context_args(browser_context_args): - browser_context_args['ignore_https_errors'] = True + browser_context_args.update( + dict( + ignore_https_errors=True, + locale='en_US', + timezone_id='Europe/Berlin', + ) + ) return browser_context_args diff --git a/src/inventory_project/tests/test_admin.py b/src/inventory_project/tests/test_admin.py index 5a10e44..1d85399 100644 --- a/src/inventory_project/tests/test_admin.py +++ b/src/inventory_project/tests/test_admin.py @@ -1,9 +1,4 @@ -from django.contrib.auth.models import User -from django.test import TestCase, override_settings -from django_processinfo.models import ProcessInfo, SiteStatistics -from model_bakery import baker - -from inventory.permissions import get_or_create_normal_user_group +from django.test import TestCase class AdminAnonymousTests(TestCase): @@ -22,59 +17,3 @@ class AdminAnonymousTests(TestCase): self.assertRedirects( response, expected_url='/admin/login/?next=/admin/', fetch_redirect_response=False ) - - -@override_settings(SECURE_SSL_REDIRECT=False) -class ProcessinfoAdminTestCase(TestCase): - @classmethod - def setUpTestData(cls): - cls.superuser = baker.make( - User, is_staff=True, is_active=True, is_superuser=True - ) - cls.normaluser = baker.make( - User, is_staff=True, is_active=True, is_superuser=False - ) - assert cls.normaluser.user_permissions.count() == 0 - group = get_or_create_normal_user_group()[0] - cls.normaluser.groups.set([group]) - - def test_superuser_access(self): - self.client.force_login(self.superuser) - - assert SiteStatistics.objects.count() == 0 - assert ProcessInfo.objects.count() == 0 - - response = self.client.get('/admin/django_processinfo/sitestatistics/') - self.assertTemplateUsed(response, 'admin/django_processinfo/change_list.html') - - response = response.content.decode('utf-8') - self.assertInHTML('

System information

', response) - self.assertInHTML('
Living processes (current/avg/max)
', response) - - assert SiteStatistics.objects.count() == 1 - assert ProcessInfo.objects.count() == 1 - - response = self.client.get('/admin/django_processinfo/processinfo/') - self.assertTemplateUsed(response, 'admin/django_processinfo/change_list.html') - - response = response.content.decode('utf-8') - self.assertInHTML('

System information

', response) - self.assertInHTML('
Living processes (current/avg/max)
', response) - - assert SiteStatistics.objects.count() == 1 - assert ProcessInfo.objects.count() == 1 - - def test_normal_user_access(self): - self.client.force_login(self.normaluser) - - assert SiteStatistics.objects.count() == 0 - assert ProcessInfo.objects.count() == 0 - - response = self.client.get('/admin/django_processinfo/sitestatistics/') - assert response.status_code == 403 - - response = self.client.get('/admin/django_processinfo/processinfo/') - assert response.status_code == 403 - - assert SiteStatistics.objects.count() == 1 - assert ProcessInfo.objects.count() == 1 diff --git a/src/inventory_project/tests/test_admin_item_auto_group_items_1.snapshot.html b/src/inventory_project/tests/test_admin_item_auto_group_items_1.snapshot.html index cc6ce66..2a3174b 100644 --- a/src/inventory_project/tests/test_admin_item_auto_group_items_1.snapshot.html +++ b/src/inventory_project/tests/test_admin_item_auto_group_items_1.snapshot.html @@ -24,26 +24,19 @@ - + -
- -
-
+
MockedCsrfTokenNode
@@ -322,31 +315,33 @@

Filter

-

- By Limit tree depth -

- +
+ + By Limit tree depth + + +
diff --git a/src/inventory_project/tests/test_admin_item_normal_user_create_minimal_item_1.snapshot.html b/src/inventory_project/tests/test_admin_item_normal_user_create_minimal_item_1.snapshot.html index a6c603a..d55c742 100644 --- a/src/inventory_project/tests/test_admin_item_normal_user_create_minimal_item_1.snapshot.html +++ b/src/inventory_project/tests/test_admin_item_normal_user_create_minimal_item_1.snapshot.html @@ -11,38 +11,52 @@ Internals
-
- -
- - +
+
+
+ +
+ - +
+
+
+
+ ID +
+
-
- ID -
-
-
- - - 0 -
- Internal version number of this entry. Used to protect the overwriting of an older entry. +
+
+ + + 0 +
+
+
+ Internal version number of this entry. Used to protect the overwriting of an older entry. +
+
- -
- - +
+ +
+ - +
- The user who is the owner of this entry and can manage it (will be set automatically) +
+ The user who is the owner of this entry and can manage it (will be set automatically) +
@@ -53,27 +67,35 @@
- -
- - +
+ +
+ - +
- (will be set automatically) +
+ (will be set automatically) +
- -
- - +
+ +
+ - +
- (will be set automatically) +
+ (will be set automatically) +
@@ -84,118 +106,158 @@
- -
-
- -