1
0
mirror of https://github.com/Rikj000/MoniGoMani.git synced 2022-03-06 00:08:05 +03:00

🔀 Fixed Merge Conflicts with Feature/GitHub-Action-Workflows

This commit is contained in:
Rik Helsen
2021-07-17 00:31:20 +02:00
15 changed files with 288 additions and 55 deletions

View File

@@ -0,0 +1,86 @@
import sys
sys.path.append('.')
sys.path.append('..')
from user_data.mgm_tools.mgm_hurry.FreqtradeCli import FreqtradeCli
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)
def test_set_basedir():
fc = __get_instance('.', use_logger=True)
assert fc.basedir == '.'
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
def test_set_freqtrade_binary():
fc = __get_instance('.', use_logger=True)
fc.freqtrade_binary = 'unknown'
assert fc.freqtrade_binary == 'unknown'
def test_installation_exists_should_return_bool():
fc = __get_instance('.', use_logger=True)
# without installation type
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:
from user_data.mgm_tools.mgm_hurry.LeetLogger import get_logger
logger = get_logger()
fc = FreqtradeCli(dir, logger)
return fc

View File

@@ -0,0 +1,35 @@
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

View File

@@ -0,0 +1,12 @@
from logging import Logger
from user_data.mgm_tools.mgm_hurry.LeetLogger import get_logger
import sys
sys.path.append('.')
sys.path.append('..')
def test_initialisation_logger():
logger = get_logger()
assert type(logger) is Logger

View File

@@ -0,0 +1,54 @@
from logging import Logger
import pytest
import sys
sys.path.append('.')
sys.path.append('..')
from user_data.mgm_tools.mgm_hurry.MoniGoManiCli import MoniGoManiCli
def test_initialisation():
cli = __get_instance()
assert type(cli) is MoniGoManiCli
def test_installation_exists_without_installation():
cli = __get_instance()
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