def test_get(self): """ Test if it get a value from 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.get("/etc/keystone/keys.conf", "sql", "connection"), "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.get, "/etc/key/keystone.conf", "sql", "connection", )
def test_get(self): ''' Test if it get a value from 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.get('/etc/keystone/keys.conf', 'sql', 'connection'), '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.get, '/etc/key/keystone.conf', 'sql', 'connection')