def test_absent(self): ''' Test to ensure that named action is absent ''' name = 'Auto registration Databases' ret = {'name': name, 'result': False, 'comment': '', 'changes': {}} with patch.dict(zabbix_action.__opts__, {'test': False}): with patch.dict(zabbix_action.__salt__, { 'zabbix.get_object_id_by_params': MagicMock(return_value=False) }): ret['result'] = True ret['comment'] = 'Zabbix Action "{0}" does not exist.'.format( name) self.assertDictEqual(zabbix_action.absent(name), ret) with patch.dict( zabbix_action.__salt__, {'zabbix.get_object_id_by_params': MagicMock(return_value=11) }): with patch.dict( zabbix_action.__salt__, {'zabbix.run_query': MagicMock(return_value=True)}): ret['result'] = True ret['comment'] = 'Zabbix Action "{0}" deleted.'.format( name) ret['changes'] = { name: { 'old': 'Zabbix Action "{0}" existed.'.format(name), 'new': 'Zabbix Action "{0}" deleted.'.format(name) } } self.assertDictEqual(zabbix_action.absent(name), ret)
def test_absent(): """ Test to ensure that named action is absent """ name = "Auto registration Databases" ret = {"name": name, "result": False, "comment": "", "changes": {}} with patch.dict(zabbix_action.__opts__, {"test": False}): with patch.dict( zabbix_action.__salt__, {"zabbix.get_object_id_by_params": MagicMock(return_value=False)}, ): ret["result"] = True ret["comment"] = 'Zabbix Action "{}" does not exist.'.format(name) assert zabbix_action.absent(name) == ret with patch.dict( zabbix_action.__salt__, {"zabbix.get_object_id_by_params": MagicMock(return_value=11)}, ): with patch.dict( zabbix_action.__salt__, {"zabbix.run_query": MagicMock(return_value=True)}, ): ret["result"] = True ret["comment"] = 'Zabbix Action "{}" deleted.'.format(name) ret["changes"] = { name: { "old": 'Zabbix Action "{}" existed.'.format(name), "new": 'Zabbix Action "{}" deleted.'.format(name), } } assert zabbix_action.absent(name) == ret
def test_absent_test_mode(self): """ Test to ensure that named action is absent in test mode """ name = "Auto registration Databases" ret = {"name": name, "result": False, "comment": "", "changes": {}} with patch.dict(zabbix_action.__opts__, {"test": True}): with patch.dict( zabbix_action.__salt__, {"zabbix.get_object_id_by_params": MagicMock(return_value=11)}, ): ret["result"] = True ret["comment"] = 'Zabbix Action "{0}" would be deleted.'.format( name) ret["changes"] = { name: { "old": 'Zabbix Action "{0}" exists.'.format(name), "new": 'Zabbix Action "{0}" would be deleted.'.format(name), } } self.assertDictEqual(zabbix_action.absent(name), ret)