forked from LBRYCommunity/lbry-sdk
test add/remove/list subscriptions
This commit is contained in:
parent
e449cd01ba
commit
4b88b191e7
3 changed files with 18 additions and 1 deletions
|
@ -3030,6 +3030,19 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
}
|
}
|
||||||
return base58.b58encode(json.dumps(export, separators=(',', ':')))
|
return base58.b58encode(json.dumps(export, separators=(',', ':')))
|
||||||
|
|
||||||
|
@requires(WALLET_COMPONENT)
|
||||||
|
def jsonrpc_channel_subscription_list(self):
|
||||||
|
"""
|
||||||
|
List subscribed channels and modes.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
channel_subscription_list
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(list) [(channel_id, download_latest, download_all)]
|
||||||
|
"""
|
||||||
|
return self.storage.get_subscriptions()
|
||||||
|
|
||||||
@requires(WALLET_COMPONENT)
|
@requires(WALLET_COMPONENT)
|
||||||
def jsonrpc_channel_subscribe(self, channel_id, download_latest=None, download_all=False):
|
def jsonrpc_channel_subscribe(self, channel_id, download_latest=None, download_all=False):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -553,7 +553,7 @@ class SQLiteStorage(SQLiteMixin):
|
||||||
(channel_id, download_latest or 0, 1 if download_all else 0))
|
(channel_id, download_latest or 0, 1 if download_all else 0))
|
||||||
|
|
||||||
def remove_subscription(self, channel_id):
|
def remove_subscription(self, channel_id):
|
||||||
return self.db.execute_fetchall("delete from subscriptions where channel_id=?", (channel_id,))
|
return self.db.execute_fetchall("delete from subscription where channel_id=?", (channel_id,))
|
||||||
|
|
||||||
def get_subscriptions(self):
|
def get_subscriptions(self):
|
||||||
return self.db.execute_fetchall("select channel_id, download_latest, download_all from subscription")
|
return self.db.execute_fetchall("select channel_id, download_latest, download_all from subscription")
|
||||||
|
|
|
@ -618,3 +618,7 @@ class TestProactiveDownloaderComponent(CommandTestCase):
|
||||||
await proactive_downloader.start()
|
await proactive_downloader.start()
|
||||||
await proactive_downloader.finished_iteration.wait()
|
await proactive_downloader.finished_iteration.wait()
|
||||||
await self.assertFileList(content1, content2)
|
await self.assertFileList(content1, content2)
|
||||||
|
|
||||||
|
self.assertEqual([(channel_id, 0, 1)], await self.daemon.jsonrpc_channel_subscription_list())
|
||||||
|
await self.daemon.jsonrpc_channel_unsubscribe(channel_id)
|
||||||
|
self.assertEqual([], await self.daemon.jsonrpc_channel_subscription_list())
|
||||||
|
|
Loading…
Reference in a new issue