def test_make_copy_orig_ports_conf_exception(mock_copy_file, mock_exists, mock_module): # ports.conf does not exist mock_exists.return_value = False mock_copy_file.side_effect = IOError('permission denied') cl_ports.make_copy_of_orig_ports_conf(mock_module) _msg = 'Failed to save the original /etc/cumulus/ports.conf: permission denied' mock_module.fail_json.assert_called_with(msg=_msg)
def test_make_copy_orig_ports_conf_exception(mock_copy_file, mock_exists, mock_module): # ports.conf does not exist mock_exists.return_value = False mock_copy_file.side_effect = IOError('permission denied') cl_ports.make_copy_of_orig_ports_conf(mock_module) _msg = 'Failed to save the original /etc/cumulus/ports.conf: permission denied' mock_module.fail_json.assert_called_with(msg=_msg)
def test_make_copy_of_orig_ports_conf(mock_module, mock_copy_file, mock_exists): # ports.conf.orig exists. mock_exists.return_value = True cl_ports.make_copy_of_orig_ports_conf(mock_module) assert_equals(mock_copy_file.call_count, 0) mock_exists.assert_called_with('/etc/cumulus/ports.conf.orig') # ports.conf does not exist mock_exists.return_value = False cl_ports.make_copy_of_orig_ports_conf(mock_module) mock_copy_file.assert_called_with('/etc/cumulus/ports.conf', '/etc/cumulus/ports.conf.orig')
def test_make_copy_of_orig_ports_conf(mock_module, mock_copy_file, mock_exists): # ports.conf.orig exists. mock_exists.return_value = True cl_ports.make_copy_of_orig_ports_conf(mock_module) assert_equals(mock_copy_file.call_count, 0) mock_exists.assert_called_with('/etc/cumulus/ports.conf.orig') # ports.conf does not exist mock_exists.return_value = False cl_ports.make_copy_of_orig_ports_conf(mock_module) mock_copy_file.assert_called_with( '/etc/cumulus/ports.conf', '/etc/cumulus/ports.conf.orig')