2015-09-20 00:27:54 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
import Config
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures("resetSettings")
|
Rev426, Fix for nonce error on bigsites asking, Dont display error details on 404 error, Dont log Websocket close errors, Add travis pip caching and osx test, Add build status to readme, Test for site files after cloning, Test for json to db mapping, Test site deleteFiles command, Test user certificate and auth address generation, Exclude debug lines from coverage, Dont run webtests every time
2015-09-20 22:35:45 +02:00
|
|
|
class TestConfig:
|
2015-09-20 00:27:54 +02:00
|
|
|
def testParse(self):
|
|
|
|
# Defaults
|
|
|
|
config_test = Config.Config("zeronet.py".split(" "))
|
|
|
|
config_test.parse(silent=True, parse_config=False)
|
|
|
|
assert not config_test.debug
|
|
|
|
assert not config_test.debug_socket
|
|
|
|
|
|
|
|
# Test parse command line with unknown parameters (ui_password)
|
|
|
|
config_test = Config.Config("zeronet.py --debug --debug_socket --ui_password hello".split(" "))
|
|
|
|
config_test.parse(silent=True, parse_config=False)
|
|
|
|
assert config_test.debug
|
|
|
|
assert config_test.debug_socket
|
|
|
|
with pytest.raises(AttributeError):
|
|
|
|
config_test.ui_password
|
|
|
|
|
|
|
|
# More complex test
|
|
|
|
args = "zeronet.py --unknown_arg --debug --debug_socket --ui_restrict 127.0.0.1 1.2.3.4 "
|
|
|
|
args += "--another_unknown argument --use_openssl False siteSign address privatekey --inner_path users/content.json"
|
|
|
|
config_test = Config.Config(args.split(" "))
|
|
|
|
config_test.parse(silent=True, parse_config=False)
|
|
|
|
assert config_test.debug
|
|
|
|
assert "1.2.3.4" in config_test.ui_restrict
|
|
|
|
assert not config_test.use_openssl
|
|
|
|
assert config_test.inner_path == "users/content.json"
|