def _cli_error_check(self, command_response): error = command_response.get(u'error') if error: command = command_response.get(u'command') if u'data' in error: raise CLIError(command, error[u'data'][u'msg']) else: raise CLIError(command, 'Invalid command.')
def test_bad_config(self): command = "asdf poknw" self.device.native.config.side_effect = CLIError( command, "Invalid command.") with self.assertRaisesRegex(CommandError, command): self.device.config(command)
def test_bad_config_list(self): commands = ["interface Eth1", "apons"] self.device.native.config_list.side_effect = CLIError( commands[1], "Invalid command.") with self.assertRaisesRegex(CommandListError, commands[1]): self.device.config_list(commands)
def test_bad_config_list(self): commands = ['interface Eth1', 'apons'] self.device.native.config_list.side_effect = CLIError( commands[1], 'Invalid command.') with self.assertRaisesRegexp(CommandListError, commands[1]): self.device.config_list(commands)
def show(command, raw_text=False): command = command.replace(" ", "_") command = command.replace("/", "_") if raw_text: path = os.path.join(CURRNENT_DIR, "show_raw", command) else: path = os.path.join(CURRNENT_DIR, "show", command) if not os.path.isfile(path): raise CLIError(command, "Invalid command.") with open(path, "r") as f: response = f.read() if raw_text: return response else: return json.loads(response)
def show(command, raw_text=False): command = command.replace(' ', '_') command = command.replace('/', '_') if raw_text: path = os.path.join(CURRNENT_DIR, 'show_raw', command) else: path = os.path.join(CURRNENT_DIR, 'show', command) if not os.path.isfile(path): raise CLIError(command, 'Invalid command.') with open(path, 'r') as f: response = f.read() if raw_text: return response else: return json.loads(response)
def test_bad_rollback(self): self.device.native.rollback.side_effect = CLIError( "rollback", "bad rollback command") with self.assertRaises(RollbackError): self.device.rollback("bad_checkpoint")
def test_bad_rollback(self): self.device.native.rollback.side_effect = CLIError( 'rollback', 'bad rollback command') with self.assertRaises(RollbackError): self.device.rollback('bad_checkpoint')