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"
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')
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)
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)
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
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')