diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-08-20 10:01:12 +0000 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2019-08-21 03:02:23 +0000 |
commit | fbc00166dc021898a1a7dfb98672ec3bc28851b9 (patch) | |
tree | 789c60af42a259a5fb58753dc9e4485aea95db87 /share/newton_base/tests | |
parent | 4c33dac9a6735b07c5e7e0d2f67baa2f5eaeed97 (diff) |
Update windriver plugin to py3
Change-Id: I7bb1591a31de777d59ad1b96246bbc4d8e1f86f4
Issue-ID: MULTICLOUD-774
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/newton_base/tests')
-rw-r--r-- | share/newton_base/tests/test_base.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/share/newton_base/tests/test_base.py b/share/newton_base/tests/test_base.py index 15160d06..b9923d1c 100644 --- a/share/newton_base/tests/test_base.py +++ b/share/newton_base/tests/test_base.py @@ -12,11 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys import json -import mock +# import mock from rest_framework import status import unittest +if sys.version_info < (3, 0): + import mock +else: + from unittest import mock + from abc import ABCMeta from django.conf import settings from django.test import Client @@ -35,9 +41,15 @@ class MockResponse(object): pass +def get_mock_response(return_value=None): + mock_response = mock.Mock(spec=MockResponse) + mock_response.status_code = status.HTTP_200_OK + mock_response.json.return_value = return_value + return mock_response + def get_mock_session(http_actions, response_dict={}): mock_session = mock.Mock( - name='mock_session',spec=http_actions) + name='mock_session', spec=http_actions) for action in http_actions: side_effect = response_dict.get("side_effect") if side_effect and isinstance(side_effect, list): |