Skip to content

Commit

Permalink
rename func to throttled_func
Browse files Browse the repository at this point in the history
  • Loading branch information
vertti committed Jul 30, 2018
1 parent fb80964 commit affdeb8
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions freqtrade/tests/test_freqtradebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,40 +106,34 @@ def test_worker_stopped(mocker, default_conf, caplog) -> None:


def test_throttle(mocker, default_conf, caplog) -> None:
def func():
"""
Test function to throttle
"""
def throttled_func():
return 42

caplog.set_level(logging.DEBUG)
freqtrade = get_patched_freqtradebot(mocker, default_conf)

start = time.time()
result = freqtrade._throttle(func, min_secs=0.1)
result = freqtrade._throttle(throttled_func, min_secs=0.1)
end = time.time()

assert result == 42
assert end - start > 0.1
assert log_has('Throttling func for 0.10 seconds', caplog.record_tuples)
assert log_has('Throttling throttled_func for 0.10 seconds', caplog.record_tuples)

result = freqtrade._throttle(func, min_secs=-1)
result = freqtrade._throttle(throttled_func, min_secs=-1)
assert result == 42


def test_throttle_with_assets(mocker, default_conf) -> None:
def func(nb_assets=-1):
"""
Test function to throttle
"""
def throttled_func(nb_assets=-1):
return nb_assets

freqtrade = get_patched_freqtradebot(mocker, default_conf)

result = freqtrade._throttle(func, min_secs=0.1, nb_assets=666)
result = freqtrade._throttle(throttled_func, min_secs=0.1, nb_assets=666)
assert result == 666

result = freqtrade._throttle(func, min_secs=0.1)
result = freqtrade._throttle(throttled_func, min_secs=0.1)
assert result == -1


Expand Down

0 comments on commit affdeb8

Please sign in to comment.