Пример #1
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()]
Пример #2
0
 def test_find_usage_no_ta(self):
     self.cls.find_usage(use_ta=False)
     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 == []
Пример #3
0
 def test_find_usage_no_ta(self):
     self.cls.find_usage(use_ta=False)
     assert self.mock_svc1.mock_calls == [
         call.find_usage()
     ]
     assert self.mock_svc2.mock_calls == [
         call.find_usage()
     ]
     assert self.mock_ta.mock_calls == []
Пример #4
0
 def test_find_usage_no_ta(self):
     self.cls.find_usage(use_ta=False)
     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 == []
Пример #5
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()
     ]
Пример #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.find_usage()
     ]
     assert self.mock_ta.mock_calls == [
         call.update_limits({
             'SvcFoo': self.mock_svc1,
             'SvcBar': self.mock_svc2,
         })
     ]
Пример #7
0
 def test_find_usage(self):
     self.cls.find_usage()
     assert self.mock_svc1.mock_calls == [
         call._update_service_quotas(),
         call.find_usage()
     ]
     assert self.mock_svc2.mock_calls == [
         call._update_limits_from_api(),
         call._update_service_quotas(),
         call.find_usage()
     ]
     assert self.mock_ta.mock_calls == [
         call.update_limits_per_service(svc.service_name)
         for svc in self.cls.services.values()
     ]
Пример #8
0
 def test_show_usage(self, capsys):
     limits = sample_limits()
     limits['SvcFoo']['foo limit3']._add_current_usage(33)
     limits['SvcBar']['bar limit2']._add_current_usage(22)
     limits['SvcBar']['barlimit1']._add_current_usage(11)
     mock_checker = Mock(spec_set=AwsLimitChecker)
     mock_checker.get_limits.return_value = limits
     self.cls.checker = mock_checker
     with patch('awslimitchecker.runner.dict2cols') as mock_d2c:
         mock_d2c.return_value = 'd2cval'
         self.cls.show_usage()
     out, err = capsys.readouterr()
     assert out == 'd2cval\n'
     assert err == ''
     assert mock_checker.mock_calls == [
         call.find_usage(service=None),
         call.get_limits(service=None)
     ]
     assert mock_d2c.mock_calls == [
         call({
             'SvcBar/bar limit2': '22',
             'SvcBar/barlimit1': '11',
             'SvcFoo/foo limit3': '33',
         })
     ]
Пример #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(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()]
Пример #11
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()]
Пример #12
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})
     ]
Пример #13
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})
     ]
Пример #14
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 == []
     svc_name = self.cls.services['SvcFoo'].service_name
     assert self.mock_ta.mock_calls == [
         call.update_limits_per_service(svc_name)
     ]
Пример #15
0
 def test_show_usage_one_service(self, capsys):
     limits = {
         'SvcFoo': sample_limits()['SvcFoo'],
     }
     limits['SvcFoo']['foo limit3']._add_current_usage(33)
     mock_checker = Mock(spec_set=AwsLimitChecker)
     mock_checker.get_limits.return_value = limits
     self.cls.checker = mock_checker
     self.cls.service_name = 'SvcFoo'
     with patch('awslimitchecker.runner.dict2cols') as mock_d2c:
         mock_d2c.return_value = 'd2cval'
         self.cls.show_usage()
     out, err = capsys.readouterr()
     assert out == 'd2cval\n'
     assert mock_checker.mock_calls == [
         call.find_usage(service='SvcFoo'),
         call.get_limits(service='SvcFoo')
     ]
     assert mock_d2c.mock_calls == [call({
         'SvcFoo/foo limit3': '33',
     })]
Пример #16
0
 def test_show_usage_one_service(self, capsys):
     limits = {
         'SvcFoo': sample_limits()['SvcFoo'],
     }
     limits['SvcFoo']['foo limit3']._add_current_usage(33)
     mock_checker = Mock(spec_set=AwsLimitChecker)
     mock_checker.get_limits.return_value = limits
     self.cls.checker = mock_checker
     self.cls.service_name = 'SvcFoo'
     with patch('awslimitchecker.runner.dict2cols') as mock_d2c:
         mock_d2c.return_value = 'd2cval'
         self.cls.show_usage()
     out, err = capsys.readouterr()
     assert out == 'd2cval\n'
     assert mock_checker.mock_calls == [
         call.find_usage(service='SvcFoo'),
         call.get_limits(service='SvcFoo')
     ]
     assert mock_d2c.mock_calls == [
         call({
             'SvcFoo/foo limit3': '33',
         })
     ]
Пример #17
0
 def test_show_usage(self, capsys):
     limits = sample_limits()
     limits['SvcFoo']['foo limit3']._add_current_usage(33)
     limits['SvcBar']['bar limit2']._add_current_usage(22)
     limits['SvcBar']['barlimit1']._add_current_usage(11)
     mock_checker = Mock(spec_set=AwsLimitChecker)
     mock_checker.get_limits.return_value = limits
     self.cls.checker = mock_checker
     with patch('awslimitchecker.runner.dict2cols') as mock_d2c:
         mock_d2c.return_value = 'd2cval'
         self.cls.show_usage()
     out, err = capsys.readouterr()
     assert out == 'd2cval\n'
     assert mock_checker.mock_calls == [
         call.find_usage(service=None),
         call.get_limits(service=None)
     ]
     assert mock_d2c.mock_calls == [
         call({
             'SvcBar/bar limit2': '22',
             'SvcBar/barlimit1': '11',
             'SvcFoo/foo limit3': '33',
         })
     ]
Пример #18
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})]