remove redundant test-functions
This commit is contained in:
parent
38712f8120
commit
911e71cd9b
@ -110,11 +110,23 @@ def patch_freqtradebot(mocker, config) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def get_patched_freqtradebot(mocker, config) -> FreqtradeBot:
|
def get_patched_freqtradebot(mocker, config) -> FreqtradeBot:
|
||||||
|
"""
|
||||||
|
This function patches _init_modules() to not call dependencies
|
||||||
|
:param mocker: a Mocker object to apply patches
|
||||||
|
:param config: Config to pass to the bot
|
||||||
|
:return: FreqtradeBot
|
||||||
|
"""
|
||||||
patch_freqtradebot(mocker, config)
|
patch_freqtradebot(mocker, config)
|
||||||
return FreqtradeBot(config)
|
return FreqtradeBot(config)
|
||||||
|
|
||||||
|
|
||||||
def get_patched_worker(mocker, config) -> Worker:
|
def get_patched_worker(mocker, config) -> Worker:
|
||||||
|
"""
|
||||||
|
This function patches _init_modules() to not call dependencies
|
||||||
|
:param mocker: a Mocker object to apply patches
|
||||||
|
:param config: Config to pass to the bot
|
||||||
|
:return: Worker
|
||||||
|
"""
|
||||||
patch_freqtradebot(mocker, config)
|
patch_freqtradebot(mocker, config)
|
||||||
return Worker(args=None, config=config)
|
return Worker(args=None, config=config)
|
||||||
|
|
||||||
|
@ -19,47 +19,14 @@ from freqtrade.persistence import Trade
|
|||||||
from freqtrade.rpc import RPCMessageType
|
from freqtrade.rpc import RPCMessageType
|
||||||
from freqtrade.state import State
|
from freqtrade.state import State
|
||||||
from freqtrade.strategy.interface import SellCheckTuple, SellType
|
from freqtrade.strategy.interface import SellCheckTuple, SellType
|
||||||
from freqtrade.tests.conftest import (log_has, log_has_re, patch_edge,
|
from freqtrade.tests.conftest import (get_patched_freqtradebot,
|
||||||
patch_exchange, patch_get_signal,
|
get_patched_worker, log_has, log_has_re,
|
||||||
|
patch_edge, patch_exchange,
|
||||||
|
patch_freqtradebot, patch_get_signal,
|
||||||
patch_wallet)
|
patch_wallet)
|
||||||
from freqtrade.worker import Worker
|
from freqtrade.worker import Worker
|
||||||
|
|
||||||
|
|
||||||
# Functions for recurrent object patching
|
|
||||||
def patch_freqtradebot(mocker, config) -> None:
|
|
||||||
"""
|
|
||||||
This function patches _init_modules() to not call dependencies
|
|
||||||
:param mocker: a Mocker object to apply patches
|
|
||||||
:param config: Config to pass to the bot
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
mocker.patch('freqtrade.freqtradebot.RPCManager', MagicMock())
|
|
||||||
mocker.patch('freqtrade.freqtradebot.persistence.init', MagicMock())
|
|
||||||
patch_exchange(mocker)
|
|
||||||
|
|
||||||
|
|
||||||
def get_patched_freqtradebot(mocker, config) -> FreqtradeBot:
|
|
||||||
"""
|
|
||||||
This function patches _init_modules() to not call dependencies
|
|
||||||
:param mocker: a Mocker object to apply patches
|
|
||||||
:param config: Config to pass to the bot
|
|
||||||
:return: FreqtradeBot
|
|
||||||
"""
|
|
||||||
patch_freqtradebot(mocker, config)
|
|
||||||
return FreqtradeBot(config)
|
|
||||||
|
|
||||||
|
|
||||||
def get_patched_worker(mocker, config) -> Worker:
|
|
||||||
"""
|
|
||||||
This function patches _init_modules() to not call dependencies
|
|
||||||
:param mocker: a Mocker object to apply patches
|
|
||||||
:param config: Config to pass to the bot
|
|
||||||
:return: Worker
|
|
||||||
"""
|
|
||||||
patch_freqtradebot(mocker, config)
|
|
||||||
return Worker(args=None, config=config)
|
|
||||||
|
|
||||||
|
|
||||||
def patch_RPCManager(mocker) -> MagicMock:
|
def patch_RPCManager(mocker) -> MagicMock:
|
||||||
"""
|
"""
|
||||||
This function mock RPC manager to avoid repeating this code in almost every tests
|
This function mock RPC manager to avoid repeating this code in almost every tests
|
||||||
|
Loading…
Reference in New Issue
Block a user