def test_is_in_maintenance(self): mh = MatterhornController('http://example.edu') mh.instance_host_map = { 1: "http://foo", 2: "http://bar" } fake_hosts = [ { "base_url": "http://foo", "maintenance": True }, { "base_url": "http://bar", "maintenance": False } ] mh.client.hosts = Mock(return_value=[ServiceHost(x, mh.client) for x in fake_hosts]) self.assertTrue(mh.is_in_maintenance(Mock(id=1))) self.assertFalse(mh.is_in_maintenance(Mock(id=2)))
def test_is_idle(self): mh = MatterhornController('http://example.edu') mh.instance_host_map = { 1: "http://foo", 2: "http://bar" } fake_stats = { 'statistics': { 'service': [ { 'running': "1", 'serviceRegistration': { 'host': 'http://foo' } }, { 'running': "0", 'serviceRegistration': { 'host': 'http://foo' } }, { 'running': "0", 'serviceRegistration': { 'host': 'http://bar' } }, { 'running': "0", 'serviceRegistration': { 'host': 'http://bar' } }, { 'running': "1", 'serviceRegistration': { 'host': 'http://foo' } } ] } } mh.client.statistics = Mock(return_value=ServiceStatistics(fake_stats, mh.client)) self.assertFalse(mh.is_idle(Mock(id=1))) self.assertTrue(mh.is_idle(Mock(id=2)))