def test_load_not_found_strategy(): strategy = StrategyResolver() with pytest.raises( ImportError, match=r'Impossible to load Strategy \'NotFoundStrategy\'.' r' This class does not exist or contains Python code errors'): strategy._load_strategy('NotFoundStrategy')
def test_load_strategy_custom_directory(result): resolver = StrategyResolver() extra_dir = os.path.join('some', 'path') with pytest.raises( FileNotFoundError, match=r".*No such file or directory: '{}'".format(extra_dir)): resolver._load_strategy('TestStrategy', extra_dir) assert hasattr(resolver.strategy, 'populate_indicators') assert 'adx' in resolver.strategy.populate_indicators(result)
def test_load_strategy_invalid_directory(result, caplog): resolver = StrategyResolver() extra_dir = os.path.join('some', 'path') resolver._load_strategy('TestStrategy', extra_dir) assert ( 'freqtrade.strategy.resolver', logging.WARNING, 'Path "{}" does not exist'.format(extra_dir), ) in caplog.record_tuples assert hasattr(resolver.strategy, 'populate_indicators') assert 'adx' in resolver.strategy.populate_indicators(result)
def test_load_strategy_invalid_directory(result, caplog): resolver = StrategyResolver() extra_dir = path.join('some', 'path') resolver._load_strategy('TestStrategy', config={}, extra_dir=extra_dir) assert ( 'freqtrade.strategy.resolver', logging.WARNING, 'Path "{}" does not exist'.format(extra_dir), ) in caplog.record_tuples assert 'adx' in resolver.strategy.advise_indicators( result, {'pair': 'ETH/BTC'})
def test_load_strategy(result): resolver = StrategyResolver() resolver._load_strategy('TestStrategy') assert hasattr(resolver.strategy, 'populate_indicators') assert 'adx' in resolver.strategy.populate_indicators(result)