Ejemplo n.º 1
0
 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()
     ]
Ejemplo n.º 2
0
 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})
     ]
Ejemplo n.º 3
0
 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()
     ]
Ejemplo n.º 4
0
 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})]
Ejemplo n.º 5
0
 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()]
Ejemplo n.º 6
0
 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()]
Ejemplo n.º 7
0
 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()]
Ejemplo n.º 8
0
 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 == []
Ejemplo n.º 9
0
 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})
     ]
Ejemplo n.º 10
0
 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})
     ]
Ejemplo n.º 11
0
 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,
         })
     ]
Ejemplo n.º 12
0
 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})
     ]
Ejemplo n.º 13
0
 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()
     ]
Ejemplo n.º 14
0
 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 == []
Ejemplo n.º 15
0
 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()
     ]
Ejemplo n.º 16
0
 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()
     ]
Ejemplo n.º 17
0
 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,
         })
     ]
Ejemplo n.º 18
0
 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()
     ]
Ejemplo n.º 19
0
 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()
     ]
Ejemplo n.º 20
0
 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()
     ]
Ejemplo n.º 21
0
 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()
     ]
Ejemplo n.º 22
0
 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})]
Ejemplo n.º 23
0
 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})]