def test_awplus_config_lines_w_parents(self):
        lines = ["shutdown"]
        parents = ["interface port1.0.1"]
        set_module_args(dict(lines=lines, parents=parents))
        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = awplus_config.get_candidate_config(module)

        self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
            candidate_config, self.running_config))

        commands = ["interface port1.0.1", "shutdown"]
        self.execute_module(changed=True, commands=commands)
    def test_awplus_config_match_strict(self):
        lines = ["switchport", "switchport mode access", "shutdown"]
        parents = ["interface port1.0.1"]
        set_module_args(dict(lines=lines, parents=parents, match="strict"))

        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = awplus_config.get_candidate_config(module)
        self.conn.get_diff = MagicMock(
            return_value=self.cliconf_obj.get_diff(candidate_config,
                                                   self.running_config,
                                                   diff_match="strict",
                                                   path=parents))

        commands = parents + ["shutdown"]
        self.execute_module(changed=True, commands=commands, sort=False)
    def test_awplus_config_match_none(self):
        lines = ["ip address 1.2.3.4 255.255.255.0", "description test string"]
        parents = ["interface port1.0.1"]
        set_module_args(dict(lines=lines, parents=parents, match="none"))

        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = awplus_config.get_candidate_config(module)
        self.conn.get_diff = MagicMock(
            return_value=self.cliconf_obj.get_diff(candidate_config,
                                                   self.running_config,
                                                   diff_match="none",
                                                   path=parents))

        commands = parents + lines
        self.execute_module(changed=True, commands=commands, sort=False)
    def test_awplus_config_replace_block(self):
        lines = ["description test string", "test string"]
        parents = ["interface port1.0.1"]
        set_module_args(dict(lines=lines, replace="block", parents=parents))

        module = MagicMock()
        module.params = {"lines": lines, "parents": parents, "src": None}
        candidate_config = awplus_config.get_candidate_config(module)

        self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(
            candidate_config,
            self.running_config,
            diff_replace="block",
            path=parents,
        ))

        commands = parents + lines
        self.execute_module(changed=True, commands=commands)