From 4ca0d9ce5251035892a0d34523b5bf1a44f881a1 Mon Sep 17 00:00:00 2001 From: dharmendra Date: Sat, 6 May 2017 23:37:24 +0000 Subject: [PATCH] Unit test update and cleanup for nsd Unit test correcting and cleanup for nsd Change-Id: I0aa77a172df32c7a82bd3cd37ce7829e1427cb84 --- tacker/tests/unit/db/utils.py | 1 - tacker/tests/unit/nfvo/test_nfvo_plugin.py | 33 ++++++---------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/tacker/tests/unit/db/utils.py b/tacker/tests/unit/db/utils.py index 7f92c1f35..defba0c95 100644 --- a/tacker/tests/unit/db/utils.py +++ b/tacker/tests/unit/db/utils.py @@ -202,7 +202,6 @@ def get_dummy_nsd_obj(): return {'nsd': {'description': 'dummy nsd description', 'name': 'dummy_NSD', 'tenant_id': u'8819a1542a5948b68f94d4be0fd50496', - 'template': {}, 'attributes': {u'nsd': nsd_tosca_template}}} diff --git a/tacker/tests/unit/nfvo/test_nfvo_plugin.py b/tacker/tests/unit/nfvo/test_nfvo_plugin.py index d6012a5fe..738f7a4fe 100644 --- a/tacker/tests/unit/nfvo/test_nfvo_plugin.py +++ b/tacker/tests/unit/nfvo/test_nfvo_plugin.py @@ -14,7 +14,6 @@ # under the License. import codecs -import datetime import mock import os import uuid @@ -73,29 +72,6 @@ class FakeDriverManager(mock.Mock): raise nfvo.NoTasksException() -def get_fake_nsd(): - create_time = datetime.datetime(2017, 1, 19, 9, 2, 11) - return {'description': u'', - 'tenant_id': u'a81900a92bda40588c52699e1873a92f', - 'created_at': create_time, 'updated_at': None, - 'vnfds': {u'tosca.nodes.nfv.VNF1': u'vnf1', - u'tosca.nodes.nfv.VNF2': u'vnf2'}, - 'attributes': {u'nsd': u'imports: [tinku1, tinku2]\ntopology_' - 'template:\n inputs:\n vl1_name: {default: net_mgmt, ' - 'description: name of VL1 virtuallink, type: string}\n ' - 'vl2_name: {default: net0, description: name of VL2 virtuallink, ' - 'type: string}\n node_templates:\n VL1:\n properties:\n' - ' network_name: {get_input: vl1_name}\n vendor: ' - 'tacker\n type: tosca.nodes.nfv.VL\n VL2:\n ' - 'properties:\n network_name: {get_input: vl2_name}\n ' - ' vendor: tacker\n type: tosca.nodes.nfv.VL\n VNF1:\n' - ' requirements:\n - {virtualLink1: VL1}\n - {' - 'virtualLink2: VL2}\n type: tosca.nodes.nfv.VNF1\n VNF2: ' - '{type: tosca.nodes.nfv.VNF2}\ntosca_definitions_version: tosca_' - 'simple_profile_for_nfv_1_0_0\n'}, - 'id': u'eb094833-995e-49f0-a047-dfb56aaf7c4e', 'name': u'nsd'} - - def get_by_name(): return False @@ -609,7 +585,14 @@ class TestNfvoPlugin(db_base.SqlTestCase): mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()} result = self.nfvo_plugin.create_nsd(self.context, nsd_obj) self.assertIsNotNone(result) - self.assertEqual(result['name'], 'dummy_NSD') + self.assertEqual('dummy_NSD', result['name']) + self.assertIn('id', result) + self.assertEqual('dummy nsd description', result['description']) + self.assertEqual('8819a1542a5948b68f94d4be0fd50496', + result['tenant_id']) + self.assertIn('attributes', result) + self.assertIn('created_at', result) + self.assertIn('updated_at', result) @mock.patch.object(nfvo_plugin.NfvoPlugin, 'get_auth_dict') @mock.patch.object(vim_client.VimClient, 'get_vim')