def test_create_ns(self, mock_get_by_name, mock_get_vim): self._insert_dummy_ns_template() self._insert_dummy_vim() with patch.object(TackerManager, 'get_service_plugins') as \ mock_plugins: mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()} mock.patch('tacker.common.driver_manager.DriverManager', side_effect=FakeDriverManager()).start() mock_get_by_name.return_value = get_by_name() ns_obj = utils.get_dummy_ns_obj() result = self.nfvo_plugin.create_ns(self.context, ns_obj) self.assertIsNotNone(result) self.assertIn('id', result) self.assertEqual(ns_obj['ns']['nsd_id'], result['nsd_id']) self.assertEqual(ns_obj['ns']['name'], result['name']) self.assertIn('status', result) self.assertIn('tenant_id', result)
def test_create_ns_empty_description(self, mock_get_by_name, mock_get_vimi, mock_auth_dict): self._insert_dummy_ns_template() self._insert_dummy_vim() mock_auth_dict.return_value = { 'auth_url': 'http://127.0.0.1', 'token': 'DummyToken', 'project_domain_name': 'dummy_domain', 'project_name': 'dummy_project' } with patch.object(TackerManager, 'get_service_plugins') as \ mock_plugins: mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()} mock_get_by_name.return_value = get_by_name() ns_obj = utils.get_dummy_ns_obj() ns_obj['ns']['description'] = '' result = self.nfvo_plugin.create_ns(self.context, ns_obj) self.assertIn('id', result) self.assertEqual(ns_obj['ns']['name'], result['name']) self.assertEqual('', result['description'])