Beispiel #1
0
    def configure(self, contents):
        if not isinstance(contents, list):
            raise RuntimeError('contents must be a list, for now')

        contents = ['enable', 'configure'] + filter(bool, contents)   # filters out empty lines

        try:
            self.eapi.execute(contents)
        except Exception as exc:
            raise ConfigError(exc=exc, contents=contents)
Beispiel #2
0
def test_do_push_config_configerror(mock_exit, mock_isfile, mock_open, device, eb_obj):
    all_config = 'transceiver qsfp default-mode 4x10G'
    errmsg = 'test config error'
    device.api.configure.side_effect = ConfigError(Exception(errmsg), all_config)
    with pytest.raises(SystemExit):
        eb_obj.do_push_config(device)
    mock_exit.assert_called_with(
        {
            'ok': False,
            'error_type': 'config',
            'message': errmsg
        }
    )