示例#1
0
    def test_signal_args(self):
        """
        Test if return httpd signal to start, restart, or stop.
        """
        with patch(
            "salt.modules.apache._detect_os", MagicMock(return_value="apachectl")
        ):
            ret = 'Command: "apachectl -k start" completed successfully!'
            mock = MagicMock(return_value={"retcode": 1, "stderr": "", "stdout": ""})
            with patch.dict(apache.__salt__, {"cmd.run_all": mock}):
                assert apache.signal("start") == ret

            mock = MagicMock(
                return_value={"retcode": 1, "stderr": "Syntax OK", "stdout": ""}
            )
            with patch.dict(apache.__salt__, {"cmd.run_all": mock}):
                assert apache.signal("start") == "Syntax OK"

            mock = MagicMock(
                return_value={"retcode": 0, "stderr": "Syntax OK", "stdout": ""}
            )
            with patch.dict(apache.__salt__, {"cmd.run_all": mock}):
                assert apache.signal("start") == "Syntax OK"

            mock = MagicMock(
                return_value={"retcode": 1, "stderr": "", "stdout": "Salt"}
            )
            with patch.dict(apache.__salt__, {"cmd.run_all": mock}):
                assert apache.signal("start") == "Salt"
示例#2
0
    def test_signal_args(self):
        '''
        Test if return httpd signal to start, restart, or stop.
        '''
        ret = 'Command: "apachectl -k start" completed successfully!'
        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': ''})
        with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
            self.assertEqual(apache.signal('start'), ret)

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': 'Syntax OK',
                                       'stdout': ''})
        with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
            self.assertEqual(apache.signal('start'), 'Syntax OK')

        mock = MagicMock(return_value={'retcode': 0,
                                       'stderr': 'Syntax OK',
                                       'stdout': ''})
        with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
            self.assertEqual(apache.signal('start'), 'Syntax OK')

        mock = MagicMock(return_value={'retcode': 1,
                                       'stderr': '',
                                       'stdout': 'Salt'})
        with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
            self.assertEqual(apache.signal('start'), 'Salt')
示例#3
0
 def test_signal(self):
     '''
     Test if return no signal for httpd
     '''
     mock = MagicMock(return_value='')
     with patch.dict(apache.__salt__, {'cmd.run': mock}):
         self.assertEqual(apache.signal(None), None)
示例#4
0
 def test_signal(self):
     '''
     Test if return no signal for httpd
     '''
     mock = MagicMock(return_value='')
     with patch.dict(apache.__salt__, {'cmd.run': mock}):
         self.assertEqual(apache.signal(None), None)
示例#5
0
 def test_signal(self):
     '''
     Test if return no signal for httpd
     '''
     with patch('salt.modules.apache._detect_os',
                MagicMock(return_value='apachectl')):
         mock = MagicMock(return_value='')
         with patch.dict(apache.__salt__, {'cmd.run': mock}):
             self.assertEqual(apache.signal(None), None)
示例#6
0
 def test_signal(self):
     """
     Test if return no signal for httpd
     """
     with patch("salt.modules.apache._detect_os",
                MagicMock(return_value="apachectl")):
         mock = MagicMock(return_value="")
         with patch.dict(apache.__salt__, {"cmd.run": mock}):
             assert apache.signal(None) is None
示例#7
0
    def test_signal_args(self):
        '''
        Test if return httpd signal to start, restart, or stop.
        '''
        with patch('salt.modules.apache._detect_os',
                   MagicMock(return_value='apachectl')):
            ret = 'Command: "apachectl -k start" completed successfully!'
            mock = MagicMock(return_value={
                'retcode': 1,
                'stderr': '',
                'stdout': ''
            })
            with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
                self.assertEqual(apache.signal('start'), ret)

            mock = MagicMock(return_value={
                'retcode': 1,
                'stderr': 'Syntax OK',
                'stdout': ''
            })
            with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
                self.assertEqual(apache.signal('start'), 'Syntax OK')

            mock = MagicMock(return_value={
                'retcode': 0,
                'stderr': 'Syntax OK',
                'stdout': ''
            })
            with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
                self.assertEqual(apache.signal('start'), 'Syntax OK')

            mock = MagicMock(return_value={
                'retcode': 1,
                'stderr': '',
                'stdout': 'Salt'
            })
            with patch.dict(apache.__salt__, {'cmd.run_all': mock}):
                self.assertEqual(apache.signal('start'), 'Salt')