mirror of
https://github.com/Rikj000/MoniGoMani.git
synced 2022-03-06 00:08:05 +03:00
Fixing action runners
This commit is contained in:
2
.github/workflows/python-analysis.yml
vendored
2
.github/workflows/python-analysis.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
flake8 mgm-hurry --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest --doctest-modules --junitxml=tests/junit/test-results-${{ matrix.python-version }}.xml --cov=com --cov-report=xml --cov-report=html
|
||||
pytest --doctest-modules --junitxml=tests/junit/test-results-${{ matrix.python-version }}.xml --cov=. --cov-report=xml --cov-report=html
|
||||
- name: Upload pytest test results
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
||||
111
tests/mgm_hurry_freqtrade_cli_test.py
Normal file
111
tests/mgm_hurry_freqtrade_cli_test.py
Normal file
@@ -0,0 +1,111 @@
|
||||
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
|
||||
|
||||
|
||||
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_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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
31
tests/mgm_hurry_interface_test.py
Normal file
31
tests/mgm_hurry_interface_test.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
50
tests/mgm_hurry_monigomani_cli_test.py
Normal file
50
tests/mgm_hurry_monigomani_cli_test.py
Normal file
@@ -0,0 +1,50 @@
|
||||
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('.', __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
|
||||
|
||||
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
|
||||
12
tests/mgm_hurry_monigomani_logger_test.py
Normal file
12
tests/mgm_hurry_monigomani_logger_test.py
Normal file
@@ -0,0 +1,12 @@
|
||||
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
|
||||
Reference in New Issue
Block a user