mirror of
https://github.com/Rikj000/MoniGoMani.git
synced 2022-03-06 00:08:05 +03:00
Tweaking pytest and flake8 settings
This commit is contained in:
@@ -1,141 +0,0 @@
|
||||
import sys
|
||||
|
||||
sys.path.append('.')
|
||||
sys.path.append('..')
|
||||
|
||||
from user_data.mgm_tools.mgm_hurry.FreqtradeCli import FreqtradeCli
|
||||
from user_data.mgm_tools.mgm_hurry.MoniGoManiLogger import get_logger
|
||||
|
||||
|
||||
'''
|
||||
Test ininialisation
|
||||
'''
|
||||
def test_initialisation_without_logger():
|
||||
fc = __get_instance('.', use_logger=False)
|
||||
assert isinstance(fc, FreqtradeCli)
|
||||
|
||||
|
||||
def test_initialisation_with_logger():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
assert isinstance(fc, FreqtradeCli)
|
||||
|
||||
|
||||
'''
|
||||
Test basedir related
|
||||
'''
|
||||
def test_set_basedir():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
assert fc.basedir == '.'
|
||||
|
||||
|
||||
'''
|
||||
Test install_type related
|
||||
'''
|
||||
def test_set_install_type_to_source():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
fc.install_type = 'source'
|
||||
assert fc.install_type == 'source'
|
||||
|
||||
|
||||
def test_set_incorrect_install_type_should_return_none():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
fc.install_type = 'foobar'
|
||||
assert fc.install_type is None
|
||||
|
||||
|
||||
'''
|
||||
Test _get_freqtrade_binary_path
|
||||
'''
|
||||
def test_get_freqtrade_binary_path_unknown_install_type_should_return_docker_path():
|
||||
'''
|
||||
Case:
|
||||
- install_type = foobar
|
||||
Expected:
|
||||
- path is a string
|
||||
- path contains 'docker-compose' because foobar
|
||||
is an unknown install type
|
||||
'''
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
cmd = fc._get_freqtrade_binary_path('.', 'foobar')
|
||||
assert type(cmd) is str and \
|
||||
cmd.find('docker-compose') > -1
|
||||
|
||||
|
||||
def test_get_freqtrade_binary_path_docker():
|
||||
'''
|
||||
Case:
|
||||
- install_type = docker
|
||||
Expected:
|
||||
- path is a string
|
||||
- path contains 'docker-compose'
|
||||
'''
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
cmd = fc._get_freqtrade_binary_path('.', 'docker')
|
||||
assert type(cmd) is str \
|
||||
and cmd.find('docker-compose') > -1
|
||||
|
||||
|
||||
def test_get_freqtrade_binary_path_source():
|
||||
'''
|
||||
Case:
|
||||
- install_type = source
|
||||
Expected:
|
||||
- path is a string
|
||||
- path contains 'freqtrade'
|
||||
- path contains '.env'
|
||||
'''
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
cmd = fc._get_freqtrade_binary_path('.', 'source')
|
||||
assert type(cmd) is str \
|
||||
and cmd.find('freqtrade') > -1 \
|
||||
and cmd.find('.env') > -1
|
||||
|
||||
|
||||
'''
|
||||
Test installation_exists()
|
||||
'''
|
||||
def test_installation_exists_should_return_bool():
|
||||
'''
|
||||
Case:
|
||||
- without installation type
|
||||
'''
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
assert type(fc.installation_exists()) is bool
|
||||
|
||||
|
||||
def test_installation_exists_faulty_install_type():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
fc.install_type = 'foobar'
|
||||
assert fc.installation_exists() is False
|
||||
|
||||
|
||||
def test_installation_exists_faulty_freqtrade_binary():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
fc.install_type = 'source'
|
||||
fc.freqtrade_binary = 'unknown'
|
||||
assert fc.installation_exists() is False
|
||||
|
||||
|
||||
def test_installation_exists_install_type_docker():
|
||||
fc = __get_instance('.', use_logger=True)
|
||||
fc.install_type = 'docker'
|
||||
fc.freqtrade_binary = 'unknown'
|
||||
assert fc.installation_exists() is True
|
||||
|
||||
|
||||
"""
|
||||
Private helper methods
|
||||
"""
|
||||
def __get_instance(dir, use_logger=True):
|
||||
"""
|
||||
Todo:
|
||||
- Mock logger object
|
||||
- Probably mock freqtrade installation
|
||||
"""
|
||||
logger = None
|
||||
|
||||
if use_logger is True:
|
||||
logger = get_logger()
|
||||
|
||||
fc = FreqtradeCli(dir, logger)
|
||||
return fc
|
||||
@@ -1,35 +0,0 @@
|
||||
import pytest
|
||||
|
||||
"""
|
||||
This unit test file will help while splitting mgm-hurry
|
||||
into more modular code.
|
||||
|
||||
1. Create unit test for specific functionality
|
||||
- Verify unit test succeeds
|
||||
2. Split and modularize code. The interface should remain unchanged.
|
||||
3. Run unit test
|
||||
- Verify unit test still succeeds
|
||||
|
||||
Also be aware to unit test on code and cli level if differences could occur.
|
||||
|
||||
Interface mgm-hurry:
|
||||
|
||||
MGMHurry.
|
||||
up
|
||||
install_freqtrade
|
||||
install_mgm
|
||||
setup
|
||||
cleanup
|
||||
download_candle_data
|
||||
hyperopt
|
||||
hyperopt_show_results
|
||||
hyperopt_show_epoch
|
||||
hyperopt_apply_epoch
|
||||
backtest
|
||||
start_trader
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented.')
|
||||
def test_basic_usage():
|
||||
assert NotImplemented
|
||||
@@ -1,60 +0,0 @@
|
||||
from logging import Logger
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.path.append('.')
|
||||
sys.path.append('..')
|
||||
|
||||
from user_data.mgm_tools.mgm_hurry.MoniGoManiCli import MoniGoManiCli # pylint: disable=E402
|
||||
|
||||
|
||||
def test_initialisation():
|
||||
cli = __get_instance()
|
||||
assert type(cli) is MoniGoManiCli
|
||||
|
||||
|
||||
def test_installation_exists_without_installation():
|
||||
cli = __get_instance('.', __get_logger())
|
||||
result = cli.installation_exists()
|
||||
assert result is False
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_with_config_without_strategy():
|
||||
assert NotImplemented
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_without_config_with_strategy():
|
||||
assert NotImplemented
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_with_valid_installation():
|
||||
assert NotImplemented
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_create_config_files_faulty_target_dir():
|
||||
assert NotImplemented
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_create_config_files_faulty_example_file():
|
||||
assert NotImplemented
|
||||
|
||||
|
||||
"""
|
||||
Private helper methods
|
||||
"""
|
||||
def __get_instance(basedir='.', logger=None):
|
||||
cli = MoniGoManiCli(basedir, logger)
|
||||
return cli
|
||||
|
||||
def __get_logger() -> Logger:
|
||||
'''
|
||||
Todo:
|
||||
- Implement a mock-object.
|
||||
'''
|
||||
logger = Logger(name='mockme')
|
||||
return logger
|
||||
@@ -1,12 +0,0 @@
|
||||
from logging import Logger
|
||||
from user_data.mgm_tools.mgm_hurry.MoniGoManiLogger import get_logger
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.append('.')
|
||||
sys.path.append('..')
|
||||
|
||||
|
||||
def test_initialisation_logger():
|
||||
logger = get_logger()
|
||||
assert type(logger) is Logger
|
||||
2
tox.ini
2
tox.ini
@@ -1,5 +1,5 @@
|
||||
[flake8]
|
||||
ignore = E226,E302,E41
|
||||
ignore = E226,E302,E41,E402
|
||||
max-line-length = 127
|
||||
exclude = tests/*
|
||||
max-complexity = 10
|
||||
|
||||
@@ -122,8 +122,7 @@ class MoniGoManiCli:
|
||||
|
||||
return mgm_config_files
|
||||
|
||||
def _exec_cmd(self, cmd: str, save_output: bool = False,
|
||||
output_path: str = None, output_file_name: str = None) -> int:
|
||||
def _exec_cmd(self, cmd: str, save_output: bool = False, output_path: str = None, output_file_name: str = None) -> int:
|
||||
"""
|
||||
Executes shell command and logs output as debug output.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user