Browse Source

Use unittest.mock instead of third party mock

horizon recently switched from the third-party mock to unittest.mock.
This breaks heat-dashboard unit tests somehow.
We no longer support py27 and we can use the standard library
unittest.mock module. Rather than investigating the cause of
the failure, it would be nice to switch to unittest.mock.

horizon dependency is updated to 18.3.1 as unittest.mock is used
since 18.3.0 and 18.3.0 has an issue that it always requires pytest.
lower-constraints is updated to match horizon requirements.

hacking local-check-factory is disabled temporarily due to
the incompatibility with hacking 2.0 or later.
https://review.opendev.org/#/c/715690/ will recover it.

Change-Id: I517d6d7d36410c64bf48ad958b3e2115725a6491
changes/43/718543/5
Akihiro Motoki 2 years ago
parent
commit
bd68639408
  1. 2
      heat_dashboard/test/helpers.py
  2. 3
      heat_dashboard/test/tests/api/test_heat.py
  3. 3
      heat_dashboard/test/tests/api/test_heat_rest.py
  4. 2
      heat_dashboard/test/tests/content/test_stacks.py
  5. 7
      lower-constraints.txt
  6. 2
      requirements.txt
  7. 1
      test-requirements.txt
  8. 5
      tox.ini

2
heat_dashboard/test/helpers.py

@ -20,6 +20,7 @@ from importlib import import_module
import os
import traceback
import unittest
from unittest import mock
import django
from django.conf import settings
@ -30,7 +31,6 @@ from django.utils import http
from heatclient import client as heat_client
from keystoneclient.v2_0 import client as keystone_client
import mock
from neutronclient.v2_0 import client as neutron_client
from openstack_auth import user
from openstack_auth import utils

3
heat_dashboard/test/tests/api/test_heat.py

@ -11,8 +11,7 @@
# under the License.
import io
import mock
from unittest import mock
from django.conf import settings
from django.test.utils import override_settings

3
heat_dashboard/test/tests/api/test_heat_rest.py

@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import mock
from unittest import mock
from heat_dashboard.api.rest import heat
from heat_dashboard.test import helpers as test

2
heat_dashboard/test/tests/content/test_stacks.py

@ -12,13 +12,13 @@
import json
import re
from unittest import mock
from django.conf import settings
from django.core import exceptions
from django.test.utils import override_settings
from django.urls import reverse
from django.utils import html
import mock
from heatclient.common import template_format as hc_format
from openstack_dashboard import api as dashboard_api

7
lower-constraints.txt

@ -31,7 +31,7 @@ flake8-import-order==0.12
futurist==1.2.0
greenlet==0.4.10
hacking==1.1.0
horizon==17.1.0
horizon==18.3.1
idna==2.6
iso8601==0.1.11
Jinja2==2.10
@ -44,7 +44,6 @@ kombu==4.0.0
linecache2==1.0.0
MarkupSafe==1.0
mccabe==0.2.1
mock==2.0.0
monotonic==0.6
msgpack-python==0.4.0
munch==2.1.0
@ -84,7 +83,7 @@ pymongo==3.0.2
pyOpenSSL==17.1.0
pyparsing==2.1.0
pyperclip==1.5.27
pyScss==1.3.4
pyScss==1.3.7
python-cinderclient==5.0.0
python-dateutil==2.5.3
python-glanceclient==2.8.0
@ -139,7 +138,7 @@ XStatic-jquery-ui==1.10.4.1
XStatic-JQuery.quicksearch==2.0.3.1
XStatic-JQuery.TableSorter==2.14.5.1
XStatic-JSEncrypt==2.3.1.1
XStatic-mdi==1.4.57.0
XStatic-mdi==1.6.50.2
XStatic-objectpath==1.2.1.0
XStatic-Rickshaw==1.5.0.0
XStatic-roboto-fontface==0.5.0.0

2
requirements.txt

@ -12,7 +12,7 @@ python-heatclient>=1.10.0 # Apache-2.0
# This will be installed from git in OpenStack CI if the job setting
# required-projects for horizon:
horizon>=17.1.0 # Apache-2.0
horizon>=18.3.1 # Apache-2.0
xstatic-angular-uuid>=0.0.4.0 # MIT
xstatic-angular-vis>=4.16.0.0 # MIT

1
test-requirements.txt

@ -12,7 +12,6 @@ hacking>=1.1.0,<1.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
flake8-import-order==0.12 # LGPLv3
mock>=2.0.0 # BSD
nodeenv>=0.9.4 # BSD
testtools>=2.2.0 # MIT

5
tox.ini

@ -64,8 +64,9 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[hacking]
local-check-factory = horizon.hacking.checks.factory
# Temporary disabled to pass the pep8 job
# [hacking]
# local-check-factory = horizon.hacking.checks.factory
[flake8]
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,.tmp

Loading…
Cancel
Save