"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py" between
tacker-3.0.0.tar.gz and tacker-3.0.1.tar.gz

About: OpenStack Tacker builds an Open NFV Orchestrator with in-built general purpose VNF Manager to deploy and operate Virtual Network Functions (VNFs) on an NFV Platform.
The "Ussuri" series (maintained release).

test_openstack_driver.py  (tacker-3.0.0):test_openstack_driver.py  (tacker-3.0.1)
skipping to change at line 16 skipping to change at line 16
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
from keystoneauth1 import exceptions from keystoneauth1 import exceptions
import mock import mock
from oslo_config import cfg from oslo_config import cfg
from tacker import context as t_context from tacker import context as t_context
from tacker.extensions import nfvo from tacker.extensions import nfvo
from tacker.nfvo.drivers.vim import openstack_driver from tacker.nfvo.drivers.vim import openstack_driver
from tacker.tests.unit import base from tacker.tests.unit import base
from tacker.tests.unit.db import utils from tacker.tests.unit.db import utils
skipping to change at line 139 skipping to change at line 141
self.keystone.get_version.return_value = keystone_version self.keystone.get_version.return_value = keystone_version
self._test_register_vim(self.vim_obj, mock_ks_client) self._test_register_vim(self.vim_obj, mock_ks_client)
mock_ks_client.regions.list.assert_called_once_with() mock_ks_client.regions.list.assert_called_once_with()
self.keystone.initialize_client.assert_called_once_with( self.keystone.initialize_client.assert_called_once_with(
**self.auth_obj) **self.auth_obj)
def _test_register_vim(self, vim_obj, mock_ks_client): def _test_register_vim(self, vim_obj, mock_ks_client):
self.keystone.initialize_client.return_value = mock_ks_client self.keystone.initialize_client.return_value = mock_ks_client
fernet_attrs = {'encrypt.return_value': 'encrypted_password'} fernet_attrs = {'encrypt.return_value': 'encrypted_password'}
mock_fernet_obj = mock.Mock(**fernet_attrs) mock_fernet_obj = mock.Mock(**fernet_attrs)
mock_fernet_key = 'test_fernet_key' mock_fernet_key = b'test_fernet_key'
self.keystone.create_fernet_key.return_value = (mock_fernet_key, self.keystone.create_fernet_key.return_value = (mock_fernet_key,
mock_fernet_obj) mock_fernet_obj)
file_mock = mock.mock_open() self.openstack_driver.register_vim(vim_obj)
with mock.patch('six.moves.builtins.open', file_mock, create=True): with open('/tmp/' + vim_obj['id'], 'r') as f:
self.openstack_driver.register_vim(vim_obj) # asserting that file has been written correctly.
self.assertEqual('test_fernet_key', f.read())
mock_fernet_obj.encrypt.assert_called_once_with(mock.ANY) mock_fernet_obj.encrypt.assert_called_once_with(mock.ANY)
file_mock().write.assert_called_once_with('test_fernet_key') os.remove('/tmp/' + vim_obj['id'])
@mock.patch('tacker.nfvo.drivers.vim.openstack_driver.os.remove') @mock.patch('tacker.nfvo.drivers.vim.openstack_driver.os.remove')
@mock.patch('tacker.nfvo.drivers.vim.openstack_driver.os.path' @mock.patch('tacker.nfvo.drivers.vim.openstack_driver.os.path'
'.join') '.join')
def test_deregister_vim(self, mock_os_path, mock_os_remove): def test_deregister_vim(self, mock_os_path, mock_os_remove):
vim_obj = self.get_vim_obj() vim_obj = self.get_vim_obj()
vim_id = 'my_id' vim_id = 'my_id'
vim_obj['id'] = vim_id vim_obj['id'] = vim_id
file_path = CONF.vim_keys.openstack + '/' + vim_id file_path = CONF.vim_keys.openstack + '/' + vim_id
mock_os_path.return_value = file_path mock_os_path.return_value = file_path
 End of changes. 4 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)