X-Git-Url: https://git.novaco.in/?p=electrum-nvc.git;a=blobdiff_plain;f=lib%2Ftests%2Ftest_simple_config.py;h=e7c13a73d74b70e2661109d09da2dd1290289c73;hp=40d3360a3f568c01f93ef191acac1401d5a909d2;hb=99a31b0c6a30bad2cb2b8c27a748a1f25a89c107;hpb=7338ac3c5417d037b5c7a4fed4f66bdc20a322e9 diff --git a/lib/tests/test_simple_config.py b/lib/tests/test_simple_config.py index 40d3360..e7c13a7 100644 --- a/lib/tests/test_simple_config.py +++ b/lib/tests/test_simple_config.py @@ -1,3 +1,4 @@ +import ast import sys import os import unittest @@ -135,6 +136,23 @@ class Test_SimpleConfig(unittest.TestCase): config.set_key("electrum_path", another_path) self.assertEqual(another_path, config.get("electrum_path")) + def test_user_config_is_not_written_with_system_config(self): + """The user config does not contain command-line options when saved.""" + fake_read_system = lambda : {"something": "b"} + fake_read_user = lambda _: {"something": "a"} + read_user_dir = lambda : self.user_dir + self.options.update({"something": "c"}) + config = SimpleConfig(options=self.options, + read_system_config_function=fake_read_system, + read_user_config_function=fake_read_user, + read_user_dir_function=read_user_dir) + config.save_user_config() + contents = None + with open(os.path.join(self.electrum_dir, "config"), "r") as f: + contents = f.read() + result = ast.literal_eval(contents) + self.assertEqual({"something": "a"}, result) + class TestSystemConfig(unittest.TestCase):