Пример #1
0
    def test_nxapi_config(self):
        """UT: nxos module:_nxapi_config method"""

        mock_cmd = MagicMock(return_value={"nxos": {"save_config": False}})
        with patch.dict(nxos_module.__salt__, {"config.get": mock_cmd}):
            with patch(
                    "salt.modules.nxos._nxapi_request",
                    return_value="router_data",
                    autospec=True,
            ):
                result = nxos_module._nxapi_config("show version")
                self.assertEqual(result, [["show version"], "router_data"])
Пример #2
0
    def test_nxapi_config_failure(self):
        """UT: nxos module:_nxapi_config method"""

        side_effect = ["Failure", "saved_data"]

        mock_cmd = MagicMock(return_value={"nxos": {"save_config": True}})
        with patch.dict(nxos_module.__salt__, {"config.get": mock_cmd}):
            with patch(
                    "salt.modules.nxos._nxapi_request",
                    side_effect=side_effect,
                    autospec=True,
            ):
                result = nxos_module._nxapi_config("show bad_command")
                self.assertEqual(result, [["show bad_command"], "Failure"])