def test_absent(): """ Test to ensure that named template is absent """ name = "A Testing Template" ret = {"name": name, "result": False, "comment": "", "changes": {}} with patch.dict(zabbix_template.__opts__, {"test": False}): with patch.dict( zabbix_template.__salt__, {"zabbix.get_object_id_by_params": MagicMock(return_value=False)}, ): ret["result"] = True ret["comment"] = 'Zabbix Template "{}" does not exist.'.format( name) assert zabbix_template.absent(name) == ret with patch.dict( zabbix_template.__salt__, {"zabbix.get_object_id_by_params": MagicMock(return_value=11)}, ): with patch.dict( zabbix_template.__salt__, {"zabbix.run_query": MagicMock(return_value=True)}, ): ret["result"] = True ret["comment"] = 'Zabbix Template "{}" deleted.'.format(name) ret["changes"] = { name: { "old": 'Zabbix Template "{}" existed.'.format(name), "new": 'Zabbix Template "{}" deleted.'.format(name), } } assert zabbix_template.absent(name) == ret
def test_absent(self): ''' Test to ensure that named template is absent ''' name = 'A Testing Template' ret = {'name': name, 'result': False, 'comment': '', 'changes': {}} with patch.dict(zabbix_template.__opts__, {'test': False}): with patch.dict(zabbix_template.__salt__, { 'zabbix.get_object_id_by_params': MagicMock(return_value=False) }): ret['result'] = True ret['comment'] = 'Zabbix Template "{0}" does not exist.'.format( name) self.assertDictEqual(zabbix_template.absent(name), ret) with patch.dict( zabbix_template.__salt__, {'zabbix.get_object_id_by_params': MagicMock(return_value=11) }): with patch.dict( zabbix_template.__salt__, {'zabbix.run_query': MagicMock(return_value=True)}): ret['result'] = True ret['comment'] = 'Zabbix Template "{0}" deleted.'.format( name) ret['changes'] = { name: { 'old': 'Zabbix Template "{0}" existed.'.format(name), 'new': 'Zabbix Template "{0}" deleted.'.format(name) } } self.assertDictEqual(zabbix_template.absent(name), ret)