def test_get_no_sysctl_binary():
    """
    Tests the failure of get function when no binary exists
    """
    with patch("salt.utils.path.which", MagicMock(return_value=None)):
        with pytest.raises(CommandExecutionError):
            linux_sysctl.get("net.ipv4.ip_forward")
Exemple #2
0
 def test_get(self):
     '''
     Tests the return of get function
     '''
     mock_cmd = MagicMock(return_value=1)
     with patch.dict(linux_sysctl.__salt__, {'cmd.run': mock_cmd}):
         self.assertEqual(linux_sysctl.get('net.ipv4.ip_forward'), 1)
 def test_get(self):
     '''
     Tests the return of get function
     '''
     mock_cmd = MagicMock(return_value=1)
     with patch.dict(linux_sysctl.__salt__, {'cmd.run': mock_cmd}):
         self.assertEqual(linux_sysctl.get('net.ipv4.ip_forward'), 1)
 def test_get(self):
     """
     Tests the return of get function
     """
     mock_cmd = MagicMock(return_value=1)
     with patch.dict(linux_sysctl.__salt__, {"cmd.run": mock_cmd}):
         self.assertEqual(linux_sysctl.get("net.ipv4.ip_forward"), 1)
 def test_get_ignore(self):
     """
     Tests the return of get function with ignore
     """
     mock_cmd = MagicMock(return_value="")
     with patch.dict(linux_sysctl.__salt__, {"cmd.run": mock_cmd}):
         self.assertEqual(
             linux_sysctl.get("net.ipv4.ip_forward", ignore=True), "")