Merge "Fix test failures with Django 4.x"

This commit is contained in:
Zuul 2023-09-11 01:33:47 +00:00 committed by Gerrit Code Review
commit 3a2213dddf
4 changed files with 22 additions and 5 deletions

View File

@ -13,8 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from io import BytesIO
import ddt import ddt
from django.core.handlers import wsgi from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from django import forms as django_forms from django import forms as django_forms
from horizon import forms as horizon_forms from horizon import forms as horizon_forms
from unittest import mock from unittest import mock
@ -28,7 +31,8 @@ class ManilaDashboardsAdminSharesUpdateShareTypeFormTests(base.APITestCase):
def setUp(self): def setUp(self):
super(self.__class__, self).setUp() 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.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_form(self, initial): def _get_form(self, initial):
@ -202,7 +206,8 @@ class ManilaDashboardsAdminSharesCreateShareTypeFormTests(base.APITestCase):
def setUp(self): def setUp(self):
super(self.__class__, self).setUp() 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.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_form(self, **kwargs): def _get_form(self, **kwargs):

View File

@ -13,7 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from io import BytesIO
from django.core.handlers import wsgi from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from unittest import mock from unittest import mock
from manila_ui.api import manila as api from manila_ui.api import manila as api
@ -25,7 +28,8 @@ class ManilaDashboardsAdminMigrationFormTests(base.APITestCase):
def setUp(self): def setUp(self):
super(self.__class__, self).setUp() 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.request = wsgi.WSGIRequest(FAKE_ENVIRON)
def _get_initial(self): def _get_initial(self):

View File

@ -13,8 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from io import BytesIO
import ddt import ddt
from django.core.handlers import wsgi from django.core.handlers import wsgi
from django.core.handlers.wsgi import LimitedStream
from unittest import mock from unittest import mock
from manila_ui.api import manila as api_manila from manila_ui.api import manila as api_manila
@ -28,7 +31,8 @@ class CreateSnapshotTests(base.APITestCase):
def setUp(self): def setUp(self):
super(self.__class__, self).setUp() 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.request = wsgi.WSGIRequest(FAKE_ENVIRON)
self.create_snapshot = tables.CreateShareSnapshot() self.create_snapshot = tables.CreateShareSnapshot()

View File

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