def test_migrate_ovs_default_file(self, mock_restart):
# Tests that the /etc/default/openvswitch-switch file is/isn't
# migrated on the upgrade-charm hook and that no restarts are
# attempted of the openvswitch-switch service.
tests = [
('package-provided-openvswitch-switch', True),
('16.07-dpdk-openvswitch-switch', True),
('16.10-openvswitch-switch', False),
]
for sample, should_migrate in tests:
self.CONFIGS.write.reset_mock()
with open('unit_tests/%s' % sample, 'r') as f:
content = f.read()
with patch('builtins.open', mock_open(read_data=content),
create=True):
self._call_hook('upgrade-charm')
if should_migrate:
self.CONFIGS.write.assert_called_with(utils.OVS_DEFAULT)
else:
self.CONFIGS.write.assert_not_called()
self.assertEqual(0, mock_restart.call_count)
test_neutron_ovs_hooks.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录