def test_dashboard_absent(): """ Test to ensure the named grafana dashboard is deleted. """ name = "myservice" ret = {"name": name, "result": None, "changes": {}, "comment": ""} mock = MagicMock( side_effect=[ {"hosts": True, "index": False}, {"hosts": True, "index": True}, {"hosts": True, "index": True}, ] ) mock_f = MagicMock(side_effect=[True, False]) with patch.dict( grafana.__salt__, {"config.option": mock, "elasticsearch.exists": mock_f} ): pytest.raises(SaltInvocationError, grafana.dashboard_absent, name) with patch.dict(grafana.__opts__, {"test": True}): comt = "Dashboard myservice is set to be removed." ret.update({"comment": comt, "result": None}) assert grafana.dashboard_absent(name) == ret comt = "Dashboard myservice does not exist." ret.update({"comment": comt, "result": True}) assert grafana.dashboard_absent(name) == ret
def test_dashboard_absent(self): ''' Test to ensure the named grafana dashboard is deleted. ''' name = 'myservice' ret = {'name': name, 'result': None, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[{'hosts': True, 'index': False}, {'hosts': True, 'index': True}, {'hosts': True, 'index': True}]) mock_f = MagicMock(side_effect=[True, False]) with patch.dict(grafana.__salt__, {'config.option': mock, 'elasticsearch.exists': mock_f}): self.assertRaises(SaltInvocationError, grafana.dashboard_absent, name) with patch.dict(grafana.__opts__, {'test': True}): comt = ('Dashboard myservice is set to be removed.') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(grafana.dashboard_absent(name), ret) comt = ('Dashboard myservice does not exist.') ret.update({'comment': comt, 'result': True}) self.assertDictEqual(grafana.dashboard_absent(name), ret)
def test_dashboard_absent(self): """ Test to ensure the named grafana dashboard is deleted. """ name = "myservice" ret = {"name": name, "result": None, "changes": {}, "comment": ""} mock = MagicMock( side_effect=[ {"hosts": True, "index": False}, {"hosts": True, "index": True}, {"hosts": True, "index": True}, ] ) mock_f = MagicMock(side_effect=[True, False]) with patch.dict(grafana.__salt__, {"config.option": mock, "elasticsearch.exists": mock_f}): self.assertRaises(SaltInvocationError, grafana.dashboard_absent, name) with patch.dict(grafana.__opts__, {"test": True}): comt = "Dashboard myservice is set to be removed." ret.update({"comment": comt, "result": None}) self.assertDictEqual(grafana.dashboard_absent(name), ret) comt = "Dashboard myservice does not exist." ret.update({"comment": comt, "result": True}) self.assertDictEqual(grafana.dashboard_absent(name), ret)