diff --git a/build-constraints.txt b/build-constraints.txt new file mode 100644 index 0000000..b722ef6 --- /dev/null +++ b/build-constraints.txt @@ -0,0 +1 @@ +setuptools<82 diff --git a/cloudkittydashboard/dashboards/project/rating/views.py b/cloudkittydashboard/dashboards/project/rating/views.py index 87ee80c..f1e9139 100644 --- a/cloudkittydashboard/dashboards/project/rating/views.py +++ b/cloudkittydashboard/dashboards/project/rating/views.py @@ -52,7 +52,7 @@ def get_data(self): def quote(request): pricing = 0.0 - if request.is_ajax(): + if request.headers.get('x-requested-with') == 'XMLHttpRequest': if request.method == 'POST': json_data = json.loads(request.body) diff --git a/cloudkittydashboard/tests/test_predictive_pricing.py b/cloudkittydashboard/tests/test_predictive_pricing.py index 38c898b..8fad16b 100644 --- a/cloudkittydashboard/tests/test_predictive_pricing.py +++ b/cloudkittydashboard/tests/test_predictive_pricing.py @@ -36,7 +36,7 @@ def setUp(self): def _test_quote_request_not_ajax_post(self, arg): request = mock.MagicMock() if arg == 'ajax': - request.is_ajax.return_value = False + request.headers.get.return_value = None # Not an AJAX request elif arg == 'method': request.method == 'POST' resp = self.quote(request) @@ -57,7 +57,7 @@ def test_quote_does_update_request_dict(self, api_mock): {'other_key': None, 'service': 'test_service'}] request = mock.MagicMock() - request.is_ajax.return_value = True + request.headers.get.return_value = 'XMLHttpRequest' request.method = 'POST' request.body = json.dumps(body) diff --git a/tools/pip.sh b/tools/pip.sh new file mode 100755 index 0000000..eebd54e --- /dev/null +++ b/tools/pip.sh @@ -0,0 +1,3 @@ +#!/bin/bash +pip install 'pip==25.3' +pip install "$@" diff --git a/tox.ini b/tox.ini index d783310..aa778f2 100644 --- a/tox.ini +++ b/tox.ini @@ -7,11 +7,16 @@ ignore_basepython_conflict = True [testenv] basepython = python3 usedevelop = True -install_command = pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} -U {opts} {packages} +install_command = {toxinidir}/tools/pip.sh --build-constraint={toxinidir}/build-constraints.txt {opts} {packages} setenv = VIRTUAL_ENV={envdir} -deps = -r{toxinidir}/requirements.txt +deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} + -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt + pip==25.3 # Needed for build-constraints.txt + setuptools<82 # Due to deprecation of pkg_resources +allowlist_externals = + {toxinidir}/tools/pip.sh commands = stestr run --slowest {posargs} @@ -32,13 +37,16 @@ commands = coverage xml -o cover/coverage.xml [testenv:docs] -deps = -r{toxinidir}/doc/requirements.txt +deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} + -r{toxinidir}/doc/requirements.txt + setuptools<82 # Due to deprecation of pkg_resources commands = sphinx-build -W --keep-going -b html doc/source doc/build/html [testenv:pdf-docs] deps = {[testenv:docs]deps} allowlist_externals = make + {toxinidir}/tools/pip.sh commands = sphinx-build -W --keep-going -b latex doc/source doc/build/pdf make -C doc/build/pdf @@ -55,6 +63,6 @@ builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,releasenotes [testenv:releasenotes] -deps = -r{toxinidir}/doc/requirements.txt +deps = {[testenv:docs]deps} commands = sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html