Make Throttle async aware (#13027)

* Make Throttle async aware

* Lint
This commit is contained in:
Paulus Schoutsen 2018-03-09 19:38:51 -08:00 committed by GitHub
parent 652e0d45a9
commit 36361d623d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 54 additions and 48 deletions

View file

@ -280,3 +280,14 @@ class TestUtil(unittest.TestCase):
mock_random.SystemRandom.return_value = generator
assert util.get_random_string(length=3) == 'ABC'
async def test_throttle_async():
"""Test Throttle decorator with async method."""
@util.Throttle(timedelta(seconds=2))
async def test_method():
"""Only first call should return a value."""
return True
assert (await test_method()) is True
assert (await test_method()) is None