| 6 | @pytest.mark.usefixtures("resetSettings") |
| 7 | class TestConfig: |
| 8 | def testParse(self): |
| 9 | # Defaults |
| 10 | config_test = Config.Config("zeronet.py".split(" ")) |
| 11 | config_test.parse(silent=True, parse_config=False) |
| 12 | assert not config_test.debug |
| 13 | assert not config_test.debug_socket |
| 14 | |
| 15 | # Test parse command line with unknown parameters (ui_password) |
| 16 | config_test = Config.Config("zeronet.py --debug --debug_socket --ui_password hello".split(" ")) |
| 17 | config_test.parse(silent=True, parse_config=False) |
| 18 | assert config_test.debug |
| 19 | assert config_test.debug_socket |
| 20 | with pytest.raises(AttributeError): |
| 21 | config_test.ui_password |
| 22 | |
| 23 | # More complex test |
| 24 | args = "zeronet.py --unknown_arg --debug --debug_socket --ui_restrict 127.0.0.1 1.2.3.4 " |
| 25 | args += "--another_unknown argument --use_openssl False siteSign address privatekey --inner_path users/content.json" |
| 26 | config_test = Config.Config(args.split(" ")) |
| 27 | config_test.parse(silent=True, parse_config=False) |
| 28 | assert config_test.debug |
| 29 | assert "1.2.3.4" in config_test.ui_restrict |
| 30 | assert not config_test.use_openssl |
| 31 | assert config_test.inner_path == "users/content.json" |