mirror of
https://github.com/Rikj000/MoniGoMani.git
synced 2022-03-06 00:08:05 +03:00
🤖 TEST: Created unit tests for monigomani_cli.installation_exists
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
from logging import Logger
|
||||
from unittest.mock import MagicMock
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
@@ -13,21 +15,28 @@ def test_initialisation():
|
||||
cli = __get_instance()
|
||||
assert isinstance(cli, MoniGoManiCli)
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_without_installation():
|
||||
assert NotImplemented
|
||||
os.path.exists = MagicMock(return_value=False)
|
||||
mgm_cli = __get_instance()
|
||||
assert mgm_cli.installation_exists() == False
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_with_config_without_strategy():
|
||||
assert NotImplemented
|
||||
mgm_cli = __get_instance()
|
||||
mgm_cli._mgm_config_json_exists = MagicMock(return_value=True)
|
||||
mgm_cli._mgm_hyperstrategy_file_exists = MagicMock(return_value=False)
|
||||
assert mgm_cli.installation_exists() == False
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_without_config_with_strategy():
|
||||
assert NotImplemented
|
||||
mgm_cli = __get_instance()
|
||||
mgm_cli._mgm_hyperstrategy_file_exists = MagicMock(return_value=True)
|
||||
mgm_cli._mgm_config_json_exists = MagicMock(return_value=False)
|
||||
assert mgm_cli.installation_exists() == False
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_installation_exists_with_valid_installation():
|
||||
assert NotImplemented
|
||||
mgm_cli = __get_instance()
|
||||
mgm_cli._mgm_hyperstrategy_file_exists = MagicMock(return_value=True)
|
||||
mgm_cli._mgm_config_json_exists = MagicMock(return_value=True)
|
||||
assert mgm_cli.installation_exists() == True
|
||||
|
||||
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
|
||||
def test_create_config_files_faulty_target_dir():
|
||||
|
||||
@@ -49,17 +49,23 @@ class MoniGoManiCli(object):
|
||||
|
||||
:return success (bool): Whether or not the config and strategy files are found.
|
||||
"""
|
||||
if os.path.exists('{0}/user_data/mgm-config.json'.format(self.basedir)) is False:
|
||||
if self._mgm_config_json_exists() is False:
|
||||
self.logger.warning('🤷♂️ No "mgm-config.json" file found.')
|
||||
return False
|
||||
|
||||
if os.path.exists('{0}/user_data/strategies/MoniGoManiHyperStrategy.py'.format(self.basedir)) is False:
|
||||
if self._mgm_hyperstrategy_file_exists() is False:
|
||||
self.logger.warning('🤷♂️ No "MoniGoManiHyperStrategy.py" file found.')
|
||||
return False
|
||||
|
||||
self.logger.debug('👉 MoniGoManiHyperStrategy and configuration found √')
|
||||
return True
|
||||
|
||||
def _mgm_config_json_exists(self) -> bool:
|
||||
return os.path.exists('{0}/user_data/mgm-config.json'.format(self.basedir))
|
||||
|
||||
def _mgm_hyperstrategy_file_exists(self) -> bool:
|
||||
return os.path.exists('{0}/user_data/strategies/MoniGoManiHyperStrategy.py'.format(self.basedir))
|
||||
|
||||
def download_setup_mgm(self, branch: str = 'develop', target_dir: str = None):
|
||||
"""
|
||||
Install Freqtrade using a git clone to target_dir.
|
||||
|
||||
Reference in New Issue
Block a user