def test_raw_incron(self): ''' Test if it return the contents of the user's incrontab ''' mock = MagicMock(return_value='incrontab') with patch.dict(incron.__grains__, {'os_family': mock}): mock = MagicMock(return_value='salt') with patch.dict(incron.__salt__, {'cmd.run_stdout': mock}): self.assertEqual(incron.raw_incron('cybage'), 'salt')
def test_raw_incron(self): """ Test if it return the contents of the user's incrontab """ mock = MagicMock(return_value="incrontab") with patch.dict(incron.__grains__, {"os_family": mock}): mock = MagicMock(return_value="salt") with patch.dict(incron.__salt__, {"cmd.run_stdout": mock}): self.assertEqual(incron.raw_incron("cybage"), "salt")
def test_raw_incron(self): """ Test if it return the contents of the user's incrontab """ mock = MagicMock(return_value="incrontab") expected_calls = [ call( "incrontab -l cybage", python_shell=False, rstrip=False, runas="cybage" ) ] with patch.dict(incron.__grains__, {"os_family": mock}): cmd_run_mock = MagicMock(return_value="salt") with patch.dict(incron.__salt__, {"cmd.run_stdout": cmd_run_mock}): self.assertEqual(incron.raw_incron("cybage"), "salt") cmd_run_mock.assert_has_calls(expected_calls) cmd = cmd_run_mock.call_args[0][0] self.assertEqual("incrontab -l cybage", cmd) self.assertNotIn("-u", cmd)