diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2017-09-26 09:22:37 +0800 |
---|---|---|
committer | Fu Jinhua <fu.jinhua@zte.com.cn> | 2017-09-26 01:47:55 +0000 |
commit | beaf2b13fefba455e576b90b8866c94afdc2076b (patch) | |
tree | 678d9498bd1bcefd0c35652d278083340d9246b2 | |
parent | 6b18966c65a8e4f8ff5495de7ffc5579a1ceeb38 (diff) |
Fix pep8 error for vl/vnf_tests.
Change-Id: I2cbdf83cc620c90bbafc0dc9a3e4844a10b9c487
Issue-Id: VFC-453
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | lcm/ns/tests/vls/tests.py | 1 | ||||
-rw-r--r-- | lcm/ns/tests/vnfs/tests.py | 89 | ||||
-rw-r--r-- | lcm/ns/tests/vnfs/verify_test.py | 3 |
3 files changed, 44 insertions, 49 deletions
diff --git a/lcm/ns/tests/vls/tests.py b/lcm/ns/tests/vls/tests.py index efbd8654..288c70e4 100644 --- a/lcm/ns/tests/vls/tests.py +++ b/lcm/ns/tests/vls/tests.py @@ -75,7 +75,6 @@ class TestVlViews(TestCase): vl_from_vl_1 = VLInstModel.objects.filter(vldid=self.vl_id_1, ownerid=self.ns_inst_id) self.assertEqual(network_id, vl_from_vl_1[0].relatednetworkid) self.assertEqual(subnetwork_id, vl_from_vl_1[0].relatedsubnetworkid) - #self.assertEqual(self.vim_id, vl_from_vl_1[0].vimid) self.assertEqual(self.tenant, vl_from_vl_1[0].tenant) vl_from_vl_2 = VLInstModel.objects.filter(vldid=self.vl_id_2, ownerid=self.ns_inst_id) self.assertEqual(VNFFGInstModel.objects.filter(vnffgdid=self.vnffg_id, nsinstid=self.ns_inst_id)[0].vllist, diff --git a/lcm/ns/tests/vnfs/tests.py b/lcm/ns/tests/vnfs/tests.py index 5073f166..e26e7265 100644 --- a/lcm/ns/tests/vnfs/tests.py +++ b/lcm/ns/tests/vnfs/tests.py @@ -202,7 +202,6 @@ class TestTerminateVnfViews(TestCase): response = self.client.post("/api/nslcm/v1/ns/vnfs/%s" % self.nf_inst_id, data=req_data) self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code) - @mock.patch.object(restcall, 'call_req') def test_terminate_vnf(self, mock_call_req): job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id) @@ -278,6 +277,7 @@ class TestTerminateVnfViews(TestCase): else: self.failUnlessEqual(1, 1) + class TestScaleVnfViews(TestCase): def setUp(self): self.client = Client() @@ -308,44 +308,40 @@ class TestScaleVnfViews(TestCase): job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id) vnfd_info = { - "vnf_flavours":[ - { - "flavour_id":"flavour1", - "description":"", - "vdu_profiles":[ - { - "vdu_id":"vdu1Id", - "instances_minimum_number": 1, - "instances_maximum_number": 4, - "local_affinity_antiaffinity_rule":[ - { - "affinity_antiaffinity":"affinity", - "scope":"node", - } - ] - } - ], - "scaling_aspects":[ - { - "id": "demo_aspect", - "name": "demo_aspect", - "description": "demo_aspect", - "associated_group": "elementGroup1", - "max_scale_level": 5 - } - ] - } - ], - "element_groups": [ - { - "group_id": "elementGroup1", - "description": "", - "properties":{ - "name": "elementGroup1", - }, - "members": ["gsu_vm","pfu_vm"], - } - ] + "vnf_flavours": [{ + "flavour_id": "flavour1", + "description": "", + "vdu_profiles": [ + { + "vdu_id": "vdu1Id", + "instances_minimum_number": 1, + "instances_maximum_number": 4, + "local_affinity_antiaffinity_rule": [ + { + "affinity_antiaffinity": "affinity", + "scope": "node", + } + ] + } + ], + "scaling_aspects": [ + { + "id": "demo_aspect", + "name": "demo_aspect", + "description": "demo_aspect", + "associated_group": "elementGroup1", + "max_scale_level": 5 + } + ] + }], + "element_groups": [{ + "group_id": "elementGroup1", + "description": "", + "properties": { + "name": "elementGroup1", + }, + "members": ["gsu_vm","pfu_vm"] + }] } req_data = { @@ -365,15 +361,14 @@ class TestScaleVnfViews(TestCase): ] } - mock_vals = { "/api/ztevmanagerdriver/v1/1/vnfs/111/terminate": - [0, json.JSONEncoder().encode({"jobId": job_id}), '200'], - "/api/ztevmanagerdriver/v1/1/vnfs/111/terminate": [0, json.JSONEncoder().encode({"jobId": job_id}), '200'] } + def side_effect(*args): return mock_vals[args[4]] + mock_call_req.side_effect = side_effect NFManualScaleService(self.nf_inst_id, req_data).run() @@ -411,7 +406,6 @@ class TestHealVnfViews(TestCase): @mock.patch.object(restcall, "call_req") def test_heal_vnf(self, mock_call_req): - mock_vals = { "/api/ztevmanagerdriver/v1/1/vnfs/111/heal": [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'], @@ -469,6 +463,7 @@ class TestHealVnfViews(TestCase): self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run) self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0) + class TestGetVnfmInfoViews(TestCase): def setUp(self): self.client = Client() @@ -529,6 +524,7 @@ class TestGetVnfmInfoViews(TestCase): context = json.loads(response.content) self.assertEqual(expect_data, context) + class TestGetVimInfoViews(TestCase): def setUp(self): self.client = Client() @@ -563,10 +559,9 @@ class TestGetVimInfoViews(TestCase): context = json.loads(response.content) self.assertEqual(expect_data["url"], context["url"]) -vnfd_model_dict = { - 'local_storages': [ - ], +vnfd_model_dict = { + 'local_storages': [], 'vdus': [ { 'volumn_storages': [ @@ -1296,4 +1291,4 @@ vim_info = { } ] } -}
\ No newline at end of file +} diff --git a/lcm/ns/tests/vnfs/verify_test.py b/lcm/ns/tests/vnfs/verify_test.py index c2d355e3..e2368fa4 100644 --- a/lcm/ns/tests/vnfs/verify_test.py +++ b/lcm/ns/tests/vnfs/verify_test.py @@ -15,6 +15,7 @@ from django.test import TestCase, Client from rest_framework import status + class TestGetVnfViews(TestCase): def setUp(self): self.client = Client() @@ -26,4 +27,4 @@ class TestGetVnfViews(TestCase): def test_verify_vnfs(self): response = self.client.post("/api/nslcm/v1/vnfonboarding", data=self.data) - self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
\ No newline at end of file + self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code) |