Exemplo n.º 1
0
    def test_server_disable(self):
        """
        Tests if it disable a server globally
        """
        mock = MagicMock(return_value="")
        with patch.dict(netscaler.__salt__, {"config.option": mock}):
            self.assertTrue(netscaler.server_disable("serGrpName"))

            MockNSServer.flag = 2
            self.assertTrue(netscaler.server_disable("serGrpName"))

            MockNSServer.flag = None
            mock = MagicMock(side_effect=[None, MockNSServer()])
            with patch.object(netscaler, "_server_get", mock):
                self.assertFalse(netscaler.server_disable("serGrpName"))

                with patch.object(netscaler, "_connect", MagicMock(return_value=None)):
                    self.assertFalse(netscaler.server_disable("serGrpName"))
Exemplo n.º 2
0
    def test_server_disable(self):
        '''
        Tests if it disable a server globally
        '''
        mock = MagicMock(return_value='')
        with patch.dict(netscaler.__salt__, {'config.option': mock}):
            self.assertTrue(netscaler.server_disable('serGrpName'))

            MockNSServer.flag = 2
            self.assertTrue(netscaler.server_disable('serGrpName'))

            MockNSServer.flag = None
            mock = MagicMock(side_effect=[None, MockNSServer()])
            with patch.object(netscaler, '_server_get', mock):
                self.assertFalse(netscaler.server_disable('serGrpName'))

                with patch.object(netscaler, '_connect',
                                  MagicMock(return_value=None)):
                    self.assertFalse(netscaler.server_disable('serGrpName'))
Exemplo n.º 3
0
    def test_server_disable(self):
        """
        Tests if it disable a server globally
        """
        mock = MagicMock(return_value="")
        with patch.dict(netscaler.__salt__, {"config.option": mock}):
            self.assertTrue(netscaler.server_disable("serGrpName"))

            MockNSServer.flag = 2
            self.assertTrue(netscaler.server_disable("serGrpName"))

            MockNSServer.flag = None
            mock = MagicMock(side_effect=[None, MockNSServer()])
            with patch.object(netscaler, "_server_get", mock):
                self.assertFalse(netscaler.server_disable("serGrpName"))

                with patch.object(netscaler, "_connect",
                                  MagicMock(return_value=None)):
                    self.assertFalse(netscaler.server_disable("serGrpName"))