tests for options added

This commit is contained in:
hroff-1902
2019-04-11 18:07:51 +03:00
parent 3e4dd5019d
commit 8bdbfbf194
2 changed files with 148 additions and 0 deletions

View File

@@ -617,3 +617,86 @@ def test_validate_tsl(default_conf):
default_conf['trailing_stop_positive_offset'] = 0.015
Configuration(Namespace())
configuration._validate_config_consistency(default_conf)
# config['exchange'] subtree has required options in it
# so it cannot be omitted in the config
def test_load_config_default_exchange(all_conf) -> None:
del all_conf['exchange']
assert 'exchange' not in all_conf
with pytest.raises(ValidationError,
match=r'\'exchange\' is a required property'):
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
### assert 'exchange' in all_conf
# config['exchange']['name'] option is required
# so it cannot be omitted in the config
def test_load_config_default_exchange_name(all_conf) -> None:
del all_conf['exchange']['name']
assert 'name' not in all_conf['exchange']
with pytest.raises(ValidationError,
match=r'\'name\' is a required property'):
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
# config['exchange']['sandbox'] option has default value: False
# so it can be omitted in the config and the default value
# should be present in the config as the option value
def test_load_config_default_exchange_sandbox(all_conf) -> None:
del all_conf['exchange']['sandbox']
assert 'sandbox' not in all_conf['exchange']
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
assert 'sandbox' in all_conf['exchange']
assert all_conf['exchange']['sandbox'] is False
# config['exchange']['key'] option has default value: ''
# so it can be omitted in the config and the default value
# should be present in the config as the option value
def test_load_config_default_exchange_key(all_conf) -> None:
del all_conf['exchange']['key']
assert 'key' not in all_conf['exchange']
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
assert 'key' in all_conf['exchange']
assert all_conf['exchange']['key'] == ''
# config['exchange']['secret'] option has default value: ''
# so it can be omitted in the config and the default value
# should be present in the config as the option value
def test_load_config_default_exchange_secret(all_conf) -> None:
del all_conf['exchange']['secret']
assert 'secret' not in all_conf['exchange']
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
assert 'secret' in all_conf['exchange']
assert all_conf['exchange']['secret'] == ''
# config['exchange']['password'] option has default value: ''
# so it can be omitted in the config and the default value
# should be present in the config as the option value
def test_load_config_default_exchange_password(all_conf) -> None:
del all_conf['exchange']['password']
assert 'password' not in all_conf['exchange']
configuration = Configuration(Namespace())
configuration._validate_config_schema(all_conf)
assert 'password' in all_conf['exchange']
assert all_conf['exchange']['password'] == ''