def test_absent(self): """ Test to ensure a search is absent. """ name = "API Error Search" ret = {"name": name, "result": None, "comment": ""} mock = MagicMock(side_effect=[True, False]) with patch.dict(splunk_search.__salt__, {"splunk_search.get": mock}): with patch.dict(splunk_search.__opts__, {"test": True}): comt = "Would delete {0}".format(name) ret.update({"comment": comt}) self.assertDictEqual(splunk_search.absent(name), ret) comt = "{0} is absent.".format(name) ret.update({"comment": comt, "result": True, "changes": {}}) self.assertDictEqual(splunk_search.absent(name), ret)
def test_absent(self): ''' Test to ensure a search is absent. ''' name = 'API Error Search' ret = {'name': name, 'result': None, 'comment': ''} mock = MagicMock(side_effect=[True, False]) with patch.dict(splunk_search.__salt__, {'splunk_search.get': mock}): with patch.dict(splunk_search.__opts__, {'test': True}): comt = ("Would delete {0}".format(name)) ret.update({'comment': comt}) self.assertDictEqual(splunk_search.absent(name), ret) comt = ('{0} is absent.'.format(name)) ret.update({'comment': comt, 'result': True, 'changes': {}}) self.assertDictEqual(splunk_search.absent(name), ret)
def test_absent(): """ Test to ensure a search is absent. """ name = "API Error Search" ret = {"name": name, "result": None, "comment": ""} mock = MagicMock(side_effect=[True, False]) with patch.dict(splunk_search.__salt__, {"splunk_search.get": mock}): with patch.dict(splunk_search.__opts__, {"test": True}): comt = "Would delete {}".format(name) ret.update({"comment": comt}) assert splunk_search.absent(name) == ret comt = "{} is absent.".format(name) ret.update({"comment": comt, "result": True, "changes": {}}) assert splunk_search.absent(name) == ret