コード例 #1
0
    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",
            )
コード例 #2
0
ファイル: openstack_config_test.py プロジェクト: DaveQB/salt
    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')
コード例 #3
0
    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')