Esempio n. 1
0
    def test_ping(self):
        """
        Test for Performs a ping to a host
        """
        with patch.object(salt.utils.network, "sanitize_host", return_value="A"):
            mock_all = MagicMock(side_effect=[{"retcode": 1}, {"retcode": 0}])
            with patch.dict(network.__salt__, {"cmd.run_all": mock_all}):
                self.assertFalse(network.ping("host", return_boolean=True))

                self.assertTrue(network.ping("host", return_boolean=True))

            with patch.dict(network.__salt__, {"cmd.run": MagicMock(return_value="A")}):
                self.assertEqual(network.ping("host"), "A")
Esempio n. 2
0
    def test_ping(self):
        '''
        Test for Performs a ping to a host
        '''
        with patch.object(salt.utils.network, 'sanitize_host',
                          return_value='A'):
            mock_all = MagicMock(side_effect=[{'retcode': 1}, {'retcode': 0}])
            with patch.dict(network.__salt__, {'cmd.run_all': mock_all}):
                self.assertFalse(network.ping('host', return_boolean=True))

                self.assertTrue(network.ping('host', return_boolean=True))

            with patch.dict(network.__salt__, {'cmd.run':
                                               MagicMock(return_value='A')}):
                self.assertEqual(network.ping('host'), 'A')
Esempio n. 3
0
    def test_ping(self):
        '''
        Test for Performs a ping to a host
        '''
        with patch.object(salt.utils.network, 'sanitize_host',
                          return_value='A'):
            mock_all = MagicMock(side_effect=[{'retcode': 1}, {'retcode': 0}])
            with patch.dict(network.__salt__, {'cmd.run_all': mock_all}):
                self.assertFalse(network.ping('host', return_boolean=True))

                self.assertTrue(network.ping('host', return_boolean=True))

            with patch.dict(network.__salt__, {'cmd.run':
                                               MagicMock(return_value='A')}):
                self.assertEqual(network.ping('host'), 'A')