def test_check_thresholds(self): self.mock_svc1.check_thresholds.return_value = { 'foo': 'bar', 'baz': 'blam', } self.mock_svc2.check_thresholds.return_value = {} res = self.cls.check_thresholds() assert res == { 'SvcFoo': { 'foo': 'bar', 'baz': 'blam', } } assert self.mock_ta.mock_calls == [ call.update_limits(), ] assert self.mock_svc1.mock_calls == [ call._update_service_quotas(), call.check_thresholds() ] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call._update_service_quotas(), call.check_thresholds() ]
def test_find_usage_service(self): self.cls.find_usage(service='SvcFoo') assert self.mock_svc1.mock_calls == [call.find_usage()] assert self.mock_svc2.mock_calls == [] assert self.mock_ta.mock_calls == [ call.update_limits({'SvcFoo': self.mock_svc1}) ]
def test_check_thresholds(self): self.mock_svc1.check_thresholds.return_value = { 'foo': 'bar', 'baz': 'blam', } self.mock_svc2.check_thresholds.return_value = {} res = self.cls.check_thresholds() assert res == { 'SvcFoo': { 'foo': 'bar', 'baz': 'blam', } } assert self.mock_ta.mock_calls == [ call.update_limits({ 'SvcFoo': self.mock_svc1, 'SvcBar': self.mock_svc2 }), ] assert self.mock_svc1.mock_calls == [ call.check_thresholds() ] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.check_thresholds() ]
def test_get_limits_service(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits["SvcFoo"] self.mock_svc2.get_limits.return_value = limits["SvcBar"] res = self.cls.get_limits(service="SvcFoo") assert res == {"SvcFoo": limits["SvcFoo"]} assert self.mock_ta.mock_calls == [call.update_limits({"SvcFoo": self.mock_svc1})]
def test_find_usage_service_with_api(self): self.cls.find_usage(service=['SvcBar']) assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.find_usage() ] assert self.mock_ta.mock_calls == [call.update_limits()]
def test_find_usage(self): self.cls.find_usage() assert self.mock_svc1.mock_calls == [call.find_usage()] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.find_usage() ] assert self.mock_ta.mock_calls == [call.update_limits()]
def test_find_usage_service(self): self.cls.find_usage(service=['SvcFoo']) assert self.mock_svc1.mock_calls == [ call._update_service_quotas(), call.find_usage() ] assert self.mock_svc2.mock_calls == [] assert self.mock_ta.mock_calls == [call.update_limits()]
def test_get_limits_service(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits(service=['SvcFoo']) assert res == {'SvcFoo': limits['SvcFoo']} assert self.mock_ta.mock_calls == [call.update_limits()] assert self.mock_svc1.mock_calls == [call.get_limits()] assert self.mock_svc2.mock_calls == []
def test_find_usage_service(self): self.cls.find_usage(service='SvcFoo') assert self.mock_svc1.mock_calls == [ call.find_usage() ] assert self.mock_svc2.mock_calls == [] assert self.mock_ta.mock_calls == [ call.update_limits({'SvcFoo': self.mock_svc1}) ]
def test_find_usage_service_with_api(self): self.cls.find_usage(service='SvcBar') assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.find_usage() ] assert self.mock_ta.mock_calls == [ call.update_limits({'SvcBar': self.mock_svc2}) ]
def test_get_limits_service(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits(service='SvcFoo') assert res == {'SvcFoo': limits['SvcFoo']} assert self.mock_ta.mock_calls == [ call.update_limits({ 'SvcFoo': self.mock_svc1, }) ]
def test_check_thresholds_service(self): self.mock_svc1.check_thresholds.return_value = {'foo': 'bar'} self.mock_svc2.check_thresholds.return_value = {'baz': 'blam'} res = self.cls.check_thresholds(service='SvcFoo') assert res == { 'SvcFoo': { 'foo': 'bar', } } assert self.mock_ta.mock_calls == [ call.update_limits({'SvcFoo': self.mock_svc1}) ]
def test_find_usage(self): self.cls.find_usage() assert self.mock_svc1.mock_calls == [ call.find_usage() ] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.find_usage() ] assert self.mock_ta.mock_calls == [ call.update_limits() ]
def test_check_thresholds_service(self): self.mock_svc1.check_thresholds.return_value = {'foo': 'bar'} self.mock_svc2.check_thresholds.return_value = {'baz': 'blam'} res = self.cls.check_thresholds(service=['SvcFoo']) assert res == { 'SvcFoo': { 'foo': 'bar', } } assert self.mock_ta.mock_calls == [call.update_limits()] assert self.mock_svc1.mock_calls == [call.check_thresholds()] assert self.mock_svc2.mock_calls == []
def test_get_limits(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits() assert res == limits assert self.mock_ta.mock_calls == [call.update_limits()] assert self.mock_svc1.mock_calls == [call.get_limits()] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.get_limits() ]
def test_get_limits_service_with_api(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits(service='SvcBar') assert res == {'SvcBar': limits['SvcBar']} assert self.mock_ta.mock_calls == [ call.update_limits() ] assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.get_limits() ]
def test_find_usage(self): self.cls.find_usage() assert self.mock_svc1.mock_calls == [ call.find_usage() ] assert self.mock_svc2.mock_calls == [ call.find_usage() ] assert self.mock_ta.mock_calls == [ call.update_limits({ 'SvcFoo': self.mock_svc1, 'SvcBar': self.mock_svc2, }) ]
def test_get_limits_service_with_api(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits(service='SvcBar') assert res == {'SvcBar': limits['SvcBar']} assert self.mock_ta.mock_calls == [ call.update_limits({ 'SvcBar': self.mock_svc2, }) ] assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.get_limits() ]
def test_check_thresholds_service_api(self): self.mock_svc1.check_thresholds.return_value = {'foo': 'bar'} self.mock_svc2.check_thresholds.return_value = {'baz': 'blam'} res = self.cls.check_thresholds(service='SvcBar') assert res == { 'SvcBar': { 'baz': 'blam', } } assert self.mock_ta.mock_calls == [ call.update_limits({'SvcBar': self.mock_svc2}) ] assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.check_thresholds() ]
def test_check_thresholds_service_api(self): self.mock_svc1.check_thresholds.return_value = {'foo': 'bar'} self.mock_svc2.check_thresholds.return_value = {'baz': 'blam'} res = self.cls.check_thresholds(service='SvcBar') assert res == { 'SvcBar': { 'baz': 'blam', } } assert self.mock_ta.mock_calls == [ call.update_limits() ] assert self.mock_svc1.mock_calls == [] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.check_thresholds() ]
def test_get_limits(self): limits = sample_limits() self.mock_svc1.get_limits.return_value = limits['SvcFoo'] self.mock_svc2.get_limits.return_value = limits['SvcBar'] res = self.cls.get_limits() assert res == limits assert self.mock_ta.mock_calls == [ call.update_limits({ 'SvcFoo': self.mock_svc1, 'SvcBar': self.mock_svc2, }) ] assert self.mock_svc1.mock_calls == [ call.get_limits() ] assert self.mock_svc2.mock_calls == [ call._update_limits_from_api(), call.get_limits() ]
def test_find_usage(self): self.cls.find_usage() assert self.mock_svc1.mock_calls == [call.find_usage()] assert self.mock_svc2.mock_calls == [call.find_usage()] assert self.mock_ta.mock_calls == [call.update_limits({"SvcFoo": self.mock_svc1, "SvcBar": self.mock_svc2})]
def test_check_thresholds_service(self): self.mock_svc1.check_thresholds.return_value = {"foo": "bar"} self.mock_svc2.check_thresholds.return_value = {"baz": "blam"} res = self.cls.check_thresholds(service="SvcFoo") assert res == {"SvcFoo": {"foo": "bar"}} assert self.mock_ta.mock_calls == [call.update_limits({"SvcFoo": self.mock_svc1})]