diff options
author | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2018-11-27 10:28:41 +0000 |
---|---|---|
committer | Xiaohua Zhang <xiaohua.zhang@windriver.com> | 2018-11-27 10:28:41 +0000 |
commit | 0d045c0bb7ee6e6162d2c1fc3e8031a3b067f49f (patch) | |
tree | f2e007e9d25320afaee402d0d25dae20710c5bb0 /windriver/titanium_cloud/registration/tests | |
parent | 87ba0b1dc07997db90d62df3c50cbb826fb8b828 (diff) |
Fix pep8 errors in multicloud plugin
Fix pep8 errors in registration moduel
Change-Id: I4b1d3ef1ed397c537b7904f229c0bbc07796a97e
Issue-ID: MULTICLOUD-420
Signed-off-by: Xiaohua Zhang <xiaohua.zhang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/registration/tests')
3 files changed, 49 insertions, 55 deletions
diff --git a/windriver/titanium_cloud/registration/tests/__init__.py b/windriver/titanium_cloud/registration/tests/__init__.py index afa702d3..ae1ce9db 100644 --- a/windriver/titanium_cloud/registration/tests/__init__.py +++ b/windriver/titanium_cloud/registration/tests/__init__.py @@ -11,4 +11,3 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 38a6beed..749fba62 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -22,7 +22,7 @@ from newton_base.tests import test_base from newton_base.util import VimDriverUtils MOCK_GET_TENANT_RESPONSE = { - "projects":[ + "projects": [ {"id": "1", "name": "project"}, {"id": "2", "name": "project2"}, ] @@ -34,8 +34,8 @@ MOCK_GET_FLAVOR_RESPONSE = { "id": "1", "name": "micro", "vcpus": 1, "ram": "1MB", "disk": "1G", "OS-FLV-EXT-DATA:ephemeral": False, "swap": True, "os-flavor-access:is_public": True, - "OS-FLV-DISABLED:disabled": True, "link": [{"href":1}] - }, + "OS-FLV-DISABLED:disabled": True, "link": [{"href": 1}] + }, { "id": "2", "name": "mini", "vcpus": 2, "ram": "2MB", "disk": "2G", "OS-FLV-EXT-DATA:ephemeral": True, @@ -69,7 +69,7 @@ MOCK_GET_AZ_RESPONSE = { { "zoneName": "production", "zoneState": {"available": True}, - "hosts": { "hypervisor": "kvm" } + "hosts": {"hypervisor": "kvm"} }, { "zoneName": "testing", @@ -88,9 +88,9 @@ MOCK_GET_SNAPSHOT_RESPONSE = { { "id": 1, "name": "test", "metadata": { - "architecture": "x86", "os-distro": "clearlinux", - "os-version": "276", "vendor": "intel", "version": 3, - "selflink": "test", "prev-snapshot-id": "test-id" + "architecture": "x86", "os-distro": "clearlinux", + "os-version": "276", "vendor": "intel", "version": 3, + "selflink": "test", "prev-snapshot-id": "test-id" } }, {"id": 2, "name": "test2"} @@ -117,9 +117,8 @@ TEST_REGISTER_ENDPOINT_REQUEST = { "defaultTenant": "project1" } - # HPA UT1: CPU-PINNING -MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE= { +MOCK_GET_HPA_FLAVOR_LIST1_RESPONSE = { "flavors": [ { "id": "1", "name": "micro", "vcpus": 1, "ram": "1024", @@ -170,11 +169,11 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS4_RESPONSE = { "extra_specs": { "aggregate_instance_extra_specs:storage": "local_image", "capabilities:cpu_info:model": "Haswell", - "hw:numa_nodes": "2", - "hw:numa_cpus.0": "0,1", - "hw:numa_cpus.1": "2,3,4,5", - "hw:numa_mem.0": "2048", - "hw:numa_mem.1": "2048" + "hw:numa_nodes": "2", + "hw:numa_cpus.0": "0,1", + "hw:numa_cpus.1": "2,3,4,5", + "hw:numa_mem.0": "2048", + "hw:numa_mem.1": "2048" } } @@ -183,7 +182,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS5_RESPONSE = { "extra_specs": { "aggregate_instance_extra_specs:storage": "local_image", "capabilities:cpu_info:model": "Haswell", - "hw:capabilities:cpu_info:features": "avx,acpi" + "hw:capabilities:cpu_info:features": "avx,acpi" } } @@ -192,7 +191,7 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS6_RESPONSE = { "extra_specs": { "aggregate_instance_extra_specs:storage": "local_image", "capabilities:cpu_info:model": "Haswell", - "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:4" + "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:4" } } @@ -206,7 +205,6 @@ MOCK_GET_HPA_FLAVOR_onap_mini_EXTRA_SPECS7_RESPONSE = { class TestRegistration(test_base.TestRequest): - def setUp(self): super(TestRegistration, self).setUp() self.req_to_aai_backup = restcall.req_to_aai @@ -250,19 +248,18 @@ class TestRegistration(test_base.TestRequest): self.assertEquals(status.HTTP_202_ACCEPTED, response.status_code) -# @mock.patch.object(VimDriverUtils, 'delete_vim_info') -# def test_unregister_endpoint_successfully( -# self, mock_delete_vim_info): -# mock_delete_vim_info.return_value = 0 + # @mock.patch.object(VimDriverUtils, 'delete_vim_info') + # def test_unregister_endpoint_successfully( + # self, mock_delete_vim_info): + # mock_delete_vim_info.return_value = 0 -# response = self.client.delete(( -# "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" -# "registry"), "{}", content_type="application/json", -# HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) - -# self.assertEquals(status.HTTP_202_ACCEPTED, -# response.status_code) + # response = self.client.delete(( + # "/api/multicloud-titanium_cloud/v0/windriver-hudson-dc_RegionOne/" + # "registry"), "{}", content_type="application/json", + # HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) + # self.assertEquals(status.HTTP_202_ACCEPTED, + # response.status_code) @mock.patch.object(VimDriverUtils, 'delete_vim_info') def test_fail_unregister_endpoint( @@ -305,7 +302,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -335,8 +332,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) - + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -366,7 +362,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -396,7 +392,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -426,7 +422,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -456,7 +452,7 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) + response.status_code) @mock.patch.object(VimDriverUtils, 'get_session') @mock.patch.object(VimDriverUtils, 'get_vim_info') @@ -486,5 +482,4 @@ class TestRegistration(test_base.TestRequest): HTTP_X_AUTH_TOKEN=mock_info.MOCK_TOKEN_ID) self.assertEquals(status.HTTP_202_ACCEPTED, - response.status_code) - + response.status_code) diff --git a/windriver/titanium_cloud/registration/tests/test_registration2.py b/windriver/titanium_cloud/registration/tests/test_registration2.py index a9c034a8..9f0cd4d2 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration2.py +++ b/windriver/titanium_cloud/registration/tests/test_registration2.py @@ -15,19 +15,19 @@ import mock import unittest -import json +# import json from django.test import Client from rest_framework import status -from django.core.cache import cache -from common.msapi import extsys +# from django.core.cache import cache +# from common.msapi import extsys from common.utils import restcall -from newton_base.tests import mock_info -from newton_base.tests import test_base -from newton_base.util import VimDriverUtils +# from newton_base.tests import mock_info +# from newton_base.tests import test_base +# from newton_base.util import VimDriverUtils -from newton_base.registration import registration as newton_registration +# from newton_base.registration import registration as newton_registration from titanium_cloud.registration.views import registration from newton_base.tests import test_base @@ -55,8 +55,8 @@ MOCK_GET_FLAVOR_RESPONSE = { "id": "1", "name": "micro", "vcpus": 1, "ram": "1MB", "disk": "1G", "OS-FLV-EXT-DATA:ephemeral": False, "swap": True, "os-flavor-access:is_public": True, - "OS-FLV-DISABLED:disabled": True, "link": [{"href":1}] - }, + "OS-FLV-DISABLED:disabled": True, "link": [{"href": 1}] + }, { "id": "2", "name": "mini", "vcpus": 2, "ram": "2MB", "disk": "2G", "OS-FLV-EXT-DATA:ephemeral": True, @@ -72,14 +72,15 @@ MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa = { "id": "1", "name": "onap.big", "vcpus": 6, "ram": "8192", "disk": "10", "OS-FLV-EXT-DATA:ephemeral": False, "swap": True, "os-flavor-access:is_public": True, - "OS-FLV-DISABLED:disabled": True, "link": [{"href":1}] - } + "OS-FLV-DISABLED:disabled": True, "link": [{"href": 1}] + } ] } MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa = { "hw:numa_nodes": 2 } + class TestRegistration2(unittest.TestCase): def setUp(self): self.client = Client() @@ -88,13 +89,12 @@ class TestRegistration2(unittest.TestCase): def tearDown(self): pass - def test_discover_flavors(self): restcall.req_to_aai = mock.Mock() restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) - mock_session = test_base.get_mock_session( - ["get"], {"get": { - "content": MOCK_GET_FLAVOR_RESPONSE}}), + mock_session = test_base.get_mock_session( + ["get"], {"get": { + "content": MOCK_GET_FLAVOR_RESPONSE}}), resp = self.view._discover_flavors(vimid="windriver-hudson-dc_RegionOne", session=mock_session, viminfo=MOCK_VIM_INFO) @@ -105,8 +105,8 @@ class TestRegistration2(unittest.TestCase): restcall.req_to_aai = mock.Mock() restcall.req_to_aai.return_value = (0, {}, status.HTTP_200_OK) mock_session = test_base.get_mock_session( - ["get"], {"side_effect": [{ - "content": MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa}, + ["get"], {"side_effect": [{ + "content": MOCK_GET_FLAVOR_RESPONSE_w_hpa_numa}, { "content": MOCK_GET_FLAVOR_EXTRASPECS_RESPONSE_w_hpa_numa} ]}), |