Fix test failures with Django 4.x

The wsgi.input environment variable is expected to be a stream
instead of a string.

Closes-Bug: #2034952
Change-Id: I72e88dcf07c90051ddf1c9030a2466501482de5d
This commit is contained in:
Corey Bryant 2023-09-08 14:22:49 -04:00
parent 8ffea4c82e
commit 9c7912238d
4 changed files with 22 additions and 5 deletions

View File

@ -13,8 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import BytesIO
import ddt
from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from django import forms as django_forms
from horizon import forms as horizon_forms
from unittest import mock
@ -28,7 +31,8 @@ class ManilaDashboardsAdminSharesUpdateShareTypeFormTests(base.APITestCase):
def setUp(self):
super(self.__class__, self).setUp()
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': 'fake_input'}
stream = LimitedStream(BytesIO(b"test"), 2)
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': stream}
self.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_form(self, initial):
@ -202,7 +206,8 @@ class ManilaDashboardsAdminSharesCreateShareTypeFormTests(base.APITestCase):
def setUp(self):
super(self.__class__, self).setUp()
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': 'fake_input'}
stream = LimitedStream(BytesIO(b"test"), 2)
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': stream}
self.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_form(self, **kwargs):

View File

@ -13,7 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import BytesIO
from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from unittest import mock
from manila_ui.api import manila as api
@ -25,7 +28,8 @@ class ManilaDashboardsAdminMigrationFormTests(base.APITestCase):
def setUp(self):
super(self.__class__, self).setUp()
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': 'fake_input'}
stream = LimitedStream(BytesIO(b"test"), 2)
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': stream}
self.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_initial(self):

View File

@ -13,8 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import BytesIO
import ddt
from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from unittest import mock
from manila_ui.api import manila as api_manila
@ -28,7 +31,8 @@ class CreateSnapshotTests(base.APITestCase):
def setUp(self):
super(self.__class__, self).setUp()
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': 'fake_input'}
stream = LimitedStream(BytesIO(b"test"), 2)
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': stream}
self.request = wsgi.WSGIRequest(FAKE_ENVIRON)
self.create_snapshot = tables.CreateShareSnapshot()

View File

@ -12,8 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from io import BytesIO
import ddt
from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from django.urls import reverse
from horizon import messages as horizon_messages
from openstack_dashboard.api import neutron
@ -51,7 +54,8 @@ class ShareViewTests(test.APITestCase):
self.mock_object(
neutron, "is_service_enabled", mock.Mock(return_value=[True]))
self.mock_object(horizon_messages, "success")
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': 'fake_input'}
stream = LimitedStream(BytesIO(b"test"), 2)
FAKE_ENVIRON = {'REQUEST_METHOD': 'GET', 'wsgi.input': stream}
self.request = wsgi.WSGIRequest(FAKE_ENVIRON)
self.mock_object(
api_manila, "tenant_absolute_limits",