def test_set(self): """ Test if it set a value in an OpenStack configuration file. """ mock = MagicMock(return_value={ "retcode": 0, "stderr": "error", "stdout": "salt" }) with patch.dict(openstack_config.__salt__, {"cmd.run_all": mock}): self.assertEqual( openstack_config.set_("/etc/keystone/keys.conf", "sql", "connection", "foo"), "salt", ) mock = MagicMock(return_value={ "retcode": 1, "stderr": "error", "stdout": "salt" }) with patch.dict(openstack_config.__salt__, {"cmd.run_all": mock}): self.assertRaises( CommandExecutionError, openstack_config.set_, "/etc/keystone/keystone.conf", "sql", "connection", "foo", )
def test_set(self): ''' Test if it set a value in an OpenStack configuration file. ''' mock = MagicMock(return_value={'retcode': 0, 'stderr': 'error', 'stdout': 'salt'}) with patch.dict(openstack_config.__salt__, {'cmd.run_all': mock}): self.assertEqual(openstack_config.set_('/etc/keystone/keys.conf', 'sql', 'connection', 'foo'), 'salt') mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error', 'stdout': 'salt'}) with patch.dict(openstack_config.__salt__, {'cmd.run_all': mock}): self.assertRaises(CommandExecutionError, openstack_config.set_, '/etc/keystone/keystone.conf', 'sql', 'connection', 'foo')