コード例 #1
0
ファイル: test_utils.py プロジェクト: pdecat/awslimitchecker
 def test_invoke_other_error(self):
     cls = Mock()
     cls.func.side_effect = self.other_error
     with patch('awslimitchecker.utils.time.sleep') as mock_sleep:
         with pytest.raises(BotoServerError) as ex:
             invoke_with_throttling_retries(cls.func)
     assert cls.func.mock_calls == [call()]
     assert mock_sleep.mock_calls == []
     assert ex.value.code == 'UnauthorizedOperation'
コード例 #2
0
ファイル: test_utils.py プロジェクト: pdecat/awslimitchecker
 def test_invoke_max_fail(self):
     self.num_errors = 6
     cls = Mock()
     cls.func.side_effect = self.retry_func
     with patch('awslimitchecker.utils.time.sleep') as mock_sleep:
         with pytest.raises(BotoServerError) as ex:
             invoke_with_throttling_retries(cls.func)
     assert ex.value.code == 'Throttling'
     assert cls.func.mock_calls == [
         call(), call(), call(), call(), call(), call()
     ]
     assert mock_sleep.mock_calls == [
         call(2), call(4), call(8), call(16), call(32)
     ]
コード例 #3
0
ファイル: test_utils.py プロジェクト: pdecat/awslimitchecker
 def test_invoke_ok(self):
     cls = Mock()
     cls.func.side_effect = self.retry_func
     with patch('awslimitchecker.utils.time.sleep') as mock_sleep:
         res = invoke_with_throttling_retries(cls.func)
     assert res is True
     assert cls.func.mock_calls == [call()]
     assert mock_sleep.mock_calls == []
コード例 #4
0
ファイル: test_utils.py プロジェクト: pdecat/awslimitchecker
 def test_invoke_ok_alc_args(self):
     cls = Mock()
     cls.func.side_effect = self.retry_func
     with patch('awslimitchecker.utils.time.sleep') as mock_sleep:
         res = invoke_with_throttling_retries(
             cls.func, 'zzz', 'aaa', foo='bar', alc_foo='bar')
     assert res is True
     assert cls.func.mock_calls == [call('zzz', 'aaa', foo='bar')]
     assert mock_sleep.mock_calls == []