test add/remove/list subscriptions

This commit is contained in:
Victor Shyba 2021-10-15 03:48:03 -03:00 committed by Jack Robison
parent 9cf6139557
commit 8f88e28e50
3 changed files with 18 additions and 1 deletions

View file

@ -3030,6 +3030,19 @@ class Daemon(metaclass=JSONRPCServerType):
}
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)
def jsonrpc_channel_subscribe(self, channel_id, download_latest=None, download_all=False):
"""

View file

@ -553,7 +553,7 @@ class SQLiteStorage(SQLiteMixin):
(channel_id, download_latest or 0, 1 if download_all else 0))
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):
return self.db.execute_fetchall("select channel_id, download_latest, download_all from subscription")

View file

@ -618,3 +618,7 @@ class TestProactiveDownloaderComponent(CommandTestCase):
await proactive_downloader.start()
await proactive_downloader.finished_iteration.wait()
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())