Merge "Use unittest.mock instead of mock"
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
- project:
|
||||
templates:
|
||||
- python35-charm-jobs
|
||||
- openstack-python3-ussuri-jobs
|
||||
- openstack-cover-jobs
|
||||
|
@@ -13,11 +13,6 @@ setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb
|
||||
|
||||
requests>=2.18.4
|
||||
|
||||
# Newer mock seems to have some syntax which is newer than python3.5 (e.g.
|
||||
# f'{something}'
|
||||
mock>=1.2,<4.0.0; python_version < '3.6'
|
||||
mock>=1.2; python_version >= '3.6'
|
||||
|
||||
stestr>=2.2.0
|
||||
|
||||
# Dependency of stestr. Workaround for
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"""Tests for reweight_osd action."""
|
||||
|
||||
from actions import change_osd_weight as action
|
||||
from mock import mock
|
||||
import unittest.mock as mock
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"""Tests for the list_inconsistent_objs action."""
|
||||
|
||||
from actions import list_inconsistent_objs as action
|
||||
from mock import mock
|
||||
import unittest.mock as mock
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
|
||||
|
@@ -107,9 +107,13 @@ class ListPoolsTestCase(CharmTestCase):
|
||||
|
||||
def test_getting_list_pools_with_details(self):
|
||||
"""Test getting list of pools with details."""
|
||||
self.pools = None
|
||||
|
||||
def _function_set(message):
|
||||
self.pools = json.loads(message['message'])
|
||||
self.function_set.side_effect = _function_set
|
||||
list_pools.main()
|
||||
self.function_get.assert_called_once_with("format")
|
||||
pools = json.loads(self.function_set.call_args.args[0]["message"])
|
||||
self.assertEqual(pools[0]["pool"], 1)
|
||||
self.assertEqual(pools[0]["size"], 3)
|
||||
self.assertEqual(pools[0]["min_size"], 2)
|
||||
self.assertEqual(self.pools[0]["pool"], 1)
|
||||
self.assertEqual(self.pools[0]["size"], 3)
|
||||
self.assertEqual(self.pools[0]["min_size"], 2)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
"""Tests for purge_osd action."""
|
||||
|
||||
from actions import purge_osd as action
|
||||
from mock import mock
|
||||
import unittest.mock as mock
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
import json
|
||||
import sys
|
||||
from mock import mock
|
||||
import unittest.mock as mock
|
||||
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
import unittest.mock as mock
|
||||
import subprocess
|
||||
|
||||
import test_utils
|
||||
|
@@ -3,7 +3,7 @@ import json
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
from mock import patch, MagicMock, DEFAULT, call
|
||||
from unittest.mock import patch, MagicMock, DEFAULT, call
|
||||
|
||||
# python-apt is not installed as part of test-requirements but is imported by
|
||||
# some charmhelpers modules so create a fake import.
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import mock
|
||||
import unittest.mock as mock
|
||||
|
||||
import test_utils
|
||||
|
||||
@@ -250,7 +250,7 @@ class CephUtilsTestCase(test_utils.CharmTestCase):
|
||||
def test_set_require_osd_release_raise_call_error(self, log, check_call):
|
||||
release = 'luminous'
|
||||
check_call.side_effect = utils.subprocess.CalledProcessError(
|
||||
0, mock.mock.MagicMock()
|
||||
0, mock.MagicMock()
|
||||
)
|
||||
expected_call = mock.call(
|
||||
['ceph', 'osd', 'require-osd-release', release]
|
||||
|
@@ -16,7 +16,7 @@ import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
# import the module we want to test
|
||||
os.sys.path.insert(1, os.path.join(sys.path[0], 'files/nagios'))
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
import unittest.mock as mock
|
||||
import sys
|
||||
|
||||
import test_utils
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
from ceph_hooks import check_for_upgrade
|
||||
from test_utils import CharmTestCase
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import unittest
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
def load_config():
|
||||
|
Reference in New Issue
Block a user