@@ -0,0 +1,1794 @@
+import salt.proxy.junos as junos%0A%0Aimport sys%0A%0A# Import Salt Testing Libs%0Afrom tests.support.mixins import LoaderModuleMockMixin%0Afrom tests.support.mock import MagicMock, patch%0Afrom tests.support.unit import TestCase, skipIf%0A%0Aif sys.version %3C %223%22:%0A    from six import StringIO%0Aelse:%0A    from io import BytesIO as StringIO%0A%0Atry:%0A    from jnpr.junos.device import Device%0A    from jnpr.junos.exception import ConnectError%0A    import jxmlease  # pylint: disable=unused-import%0A    from ncclient.transport.ssh import SSHSession%0A    from ncclient.devices.junos import JunosDeviceHandler%0A%0A    HAS_JUNOS = True%0Aexcept ImportError:%0A    HAS_JUNOS = False%0A%0A%0A@skipIf(not HAS_JUNOS, %22The junos-eznc and jxmlease modules are required%22)%0Aclass JunosProxyTestCase(TestCase, LoaderModuleMockMixin):%0A    def setup_loader_modules(self):%0A        return %7B%0A            junos: %7B%0A                %22__virtual__%22: MagicMock(return_value=%22junos%22),%0A                %22DETAILS%22: %7B%7D,%0A                %22__pillar__%22: %7B%7D,%0A            %7D%0A        %7D%0A%0A    def setUp(self):%0A        self.opts = %7B%22proxy%22: %7B%22username%22: %22xxxx%22, %22password%5D%22: %22xxx%22, %22host%22: %22junos%22%7D%7D%0A%0A    @patch(%22ncclient.manager.connect%22)%0A    def test_init(self, mock_connect):%0A        junos.init(self.opts)%0A        self.assertTrue(junos.thisproxy.get(%22initialized%22))%0A%0A    @patch(%22ncclient.manager.connect%22)%0A    def test_init_err(self, mock_connect):%0A        mock_connect.side_effect = ConnectError%0A        junos.init(self.opts)%0A        self.assertFalse(junos.thisproxy.get(%22initialized%22))%0A%0A    @patch(%22ncclient.manager.connect%22)%0A    def test_alive(self, mock_connect):%0A        junos.init(self.opts)%0A        junos.thisproxy%5B%22conn%22%5D._conn._session._buffer = StringIO()%0A        self.assertTrue(junos.alive(self.opts))%0A        self.assertTrue(junos.thisproxy.get(%22initialized%22))%0A

test cases for junos proxy