mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
don't reach through the tahoe-lafs config object
This commit is contained in:
parent
d2e16df5cc
commit
6068b6c1b2
@ -729,12 +729,10 @@ class _Client(node.Node, pollmixin.PollMixin):
|
||||
"""
|
||||
Load the configuration for a storage server plugin with the given name.
|
||||
|
||||
:return dict: The matching configuration.
|
||||
:return dict[bytes, bytes]: The matching configuration.
|
||||
"""
|
||||
try:
|
||||
# Need to reach past the Tahoe-LAFS-supplied wrapper around the
|
||||
# underlying ConfigParser...
|
||||
config = self.config.config.items(
|
||||
config = self.config.items(
|
||||
"storageserver.plugins." + storage_plugin_name,
|
||||
)
|
||||
except NoSectionError:
|
||||
|
@ -292,6 +292,9 @@ class _Config(object):
|
||||
"Unable to write config file '{}'".format(fn),
|
||||
)
|
||||
|
||||
def items(self, section):
|
||||
return self.config.items(section)
|
||||
|
||||
def get_config(self, section, option, default=_None, boolean=False):
|
||||
try:
|
||||
if boolean:
|
||||
|
@ -4,6 +4,7 @@ import stat
|
||||
import sys
|
||||
import time
|
||||
import mock
|
||||
from textwrap import dedent
|
||||
|
||||
from unittest import skipIf
|
||||
|
||||
@ -175,6 +176,29 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
|
||||
with self.assertRaises(Exception):
|
||||
config.get_config_from_file("it_does_not_exist", required=True)
|
||||
|
||||
def test_config_items(self):
|
||||
"""
|
||||
All items in a config section can be retrieved.
|
||||
"""
|
||||
basedir = u"test_node/test_config_items"
|
||||
create_node_dir(basedir, "testing")
|
||||
|
||||
with open(os.path.join(basedir, 'tahoe.cfg'), 'wt') as f:
|
||||
f.write(dedent(
|
||||
"""
|
||||
[node]
|
||||
nickname = foo
|
||||
timeout.disconnect = 12
|
||||
"""
|
||||
))
|
||||
config = read_config(basedir, "portnum")
|
||||
self.assertEqual(
|
||||
config.items("node"),
|
||||
[(b"nickname", b"foo"),
|
||||
(b"timeout.disconnect", b"12"),
|
||||
],
|
||||
)
|
||||
|
||||
@skipIf(
|
||||
"win32" in sys.platform.lower() or "cygwin" in sys.platform.lower(),
|
||||
"We don't know how to set permissions on Windows.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user