From 827585f169b1c97bf58dd237246515ebe42e1cfc Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Wed, 28 Mar 2018 00:09:35 +0800 Subject: Fix UT bug in test-base Change-Id: I2a281dd186f2771497289401186bfd31912b568a Issue-ID: MULTICLOUD-203 Signed-off-by: Yun Huang --- share/newton_base/tests/test_base.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/newton_base/tests/test_base.py b/share/newton_base/tests/test_base.py index 1b582ef4..15160d06 100644 --- a/share/newton_base/tests/test_base.py +++ b/share/newton_base/tests/test_base.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json import mock from rest_framework import status import unittest @@ -171,7 +172,9 @@ class AbstractTestResource(object): mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO response = self.client.post( - self.url, self.MOCK_POST_RESOURCE_REQUEST, + self.url, + data=json.dumps(self.MOCK_POST_RESOURCE_REQUEST), + content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) context = response.json() @@ -197,7 +200,9 @@ class AbstractTestResource(object): mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO response = self.client.post( - self.url, self.MOCK_POST_RESOURCE_REQUEST_EXISTING, + self.url, + data=json.dumps(self.MOCK_POST_RESOURCE_REQUEST_EXISTING), + content_type='application/json', HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) context = response.json() @@ -222,7 +227,10 @@ class AbstractTestResource(object): mock_get_vim_info.return_value = mock_info.MOCK_VIM_INFO response = self.client.post( - self.url, {}, HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + self.url, + {}, + content_type='application/json', + HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) context = response.json() self.assertIn('error', context) -- cgit 1.2.3-korg