forked from LBRYCommunity/lbry-sdk
adds settings_clear method and integration test
This commit is contained in:
parent
6022339091
commit
f7c9f6d142
2 changed files with 35 additions and 1 deletions
|
@ -21,7 +21,7 @@ from torba.client.wallet import Wallet, ENCRYPT_ON_DISK
|
|||
from torba.client.baseaccount import SingleKey, HierarchicalDeterministic
|
||||
|
||||
from lbry import utils
|
||||
from lbry.conf import Config, Setting
|
||||
from lbry.conf import Config, Setting, NOT_SET
|
||||
from lbry.blob.blob_file import is_valid_blobhash, BlobBuffer
|
||||
from lbry.blob_exchange.downloader import download_blob
|
||||
from lbry.dht.peer import make_kademlia_peer
|
||||
|
@ -1007,6 +1007,23 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
setattr(c, key, cleaned)
|
||||
return {key: cleaned}
|
||||
|
||||
def jsonrpc_settings_clear(self, key):
|
||||
"""
|
||||
Clear daemon settings
|
||||
|
||||
Usage:
|
||||
settings_clear (<key>)
|
||||
|
||||
Options:
|
||||
None
|
||||
|
||||
Returns:
|
||||
(dict) Updated dictionary of daemon settings
|
||||
"""
|
||||
with self.conf.update_config() as c:
|
||||
setattr(c, key, NOT_SET)
|
||||
return
|
||||
|
||||
PREFERENCE_DOC = """
|
||||
Preferences management.
|
||||
"""
|
||||
|
|
|
@ -10,3 +10,20 @@ class AddressManagement(CommandTestCase):
|
|||
single = await self.out(self.daemon.jsonrpc_address_list(addresses['items'][11]['address']))
|
||||
self.assertItemCount(single, 1)
|
||||
self.assertEqual(single['items'][0], addresses['items'][11])
|
||||
|
||||
async def test_settings(self):
|
||||
settings = self.daemon.jsonrpc_settings_get()
|
||||
self.assertNotEqual(settings['lbryum_servers'][0],('127.0.0.1', 50002))
|
||||
self.assertEqual(settings['lbryum_servers'][0],('127.0.0.1', 50001))
|
||||
|
||||
servers = ['server:50001', 'server2:50001']
|
||||
self.daemon.jsonrpc_settings_set('lbryum_servers', servers)
|
||||
self.daemon.jsonrpc_settings_set('use_upnp', True)
|
||||
settings2 = self.daemon.jsonrpc_settings_get()
|
||||
self.assertEqual(settings2['lbryum_servers'][0], ('server', 50001))
|
||||
self.assertEqual(settings2['use_upnp'], True)
|
||||
|
||||
self.daemon.jsonrpc_settings_clear('lbryum_servers')
|
||||
settings3 = self.daemon.jsonrpc_settings_get()
|
||||
self.assertNotEqual(settings3['lbryum_servers'][0], ('spv1.lbry.com', 50002))
|
||||
self.assertEqual(settings3['lbryum_servers'][0], ('spv1.lbry.com', 50001))
|
||||
|
|
Loading…
Reference in a new issue