Пример #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()
     ]
Пример #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})
     ]
Пример #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()
     ]
Пример #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})]
Пример #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()]
Пример #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()]
Пример #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()]
Пример #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 == []
Пример #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})
     ]
Пример #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})
     ]
Пример #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,
         })
     ]
Пример #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})
     ]
Пример #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()
     ]
Пример #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 == []
Пример #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()
     ]
Пример #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()
     ]
Пример #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,
         })
     ]
Пример #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()
     ]
Пример #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()
     ]
Пример #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()
     ]
Пример #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()
     ]
Пример #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})]
Пример #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})]