Exemplo n.º 1
0
class FakeFortiOSDevice:
    @staticmethod
    def read_txt_file(filename):
        with open(filename) as data_file:
            return data_file.read().splitlines()

    def execute_command(self, command):
        return self.read_txt_file('fortios/mock_data/{}.txt'.format(command.replace(' ', '_')))

    def load_config(self, config_block):
        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file('fortios/mock_data/{}.txt'.format(
                                                                                    config_block.replace(' ', '_'))))
Exemplo n.º 2
0
class FakeFortiOSDevice:
    @staticmethod
    def read_txt_file(filename):
        with open(filename) as data_file:
            return data_file.read().splitlines()

    def execute_command(self, command):
        return self.read_txt_file('fortios/mock_data/{}.txt'.format(
            command.replace(' ', '_').replace('|', '').replace(':', '')))

    def load_config(self, config_block):
        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(
            self.read_txt_file('fortios/mock_data/{}.txt'.format(
                config_block.replace(' ', '_'))))
Exemplo n.º 3
0
class FakeDevice(BaseTestDouble):
    """Device test double."""
    def open(self):
        pass

    def close(self):
        pass

    def execute_command(self, command):
        filename = '{}.txt'.format(self.sanitize_text(command))
        full_path = self.find_file(filename)
        return self.read_txt_file(full_path).splitlines()

    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))
Exemplo n.º 4
0
class FakeDevice(BaseTestDouble):
    """Device test double."""

    def open(self):
        pass

    def close(self):
        pass

    def execute_command(self, command):
        filename = '{}.txt'.format(self.sanitize_text(command))
        full_path = self.find_file(filename)
        return self.read_txt_file(full_path).splitlines()

    def load_config(self, config_block):
        filename = '{}.txt'.format(self.sanitize_text(config_block))
        full_path = self.find_file(filename)

        self.running_config = FortiConfig('running')
        self.running_config.parse_config_output(self.read_txt_file(full_path))