forked from LBRYCommunity/lbry-sdk
claim_list --claim_type argument can be repeated
This commit is contained in:
parent
e834209d40
commit
15a2fa6199
3 changed files with 22 additions and 4 deletions
|
@ -2154,7 +2154,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
List my stream and channel claims.
|
List my stream and channel claims.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
claim_list [--claim_type=<claim_type>]
|
claim_list [--claim_type=<claim_type>...]
|
||||||
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
|
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
|
||||||
[--page=<page>] [--page_size=<page_size>]
|
[--page=<page>] [--page_size=<page_size>]
|
||||||
[--resolve]
|
[--resolve]
|
||||||
|
|
|
@ -739,9 +739,11 @@ class Database(SQLiteMixin):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def constrain_claims(constraints):
|
def constrain_claims(constraints):
|
||||||
claim_type = constraints.pop('claim_type', None)
|
claim_types = constraints.pop('claim_type', None)
|
||||||
if claim_type is not None:
|
if isinstance(claim_types, str) and claim_types:
|
||||||
constraints['txo_type'] = TXO_TYPES[claim_type]
|
claim_types = [claim_types]
|
||||||
|
if isinstance(claim_types, list) and claim_types:
|
||||||
|
constraints['txo_type__in'] = [TXO_TYPES[ct] for ct in claim_types]
|
||||||
else:
|
else:
|
||||||
constraints['txo_type__in'] = CLAIM_TYPES
|
constraints['txo_type__in'] = CLAIM_TYPES
|
||||||
|
|
||||||
|
|
|
@ -384,6 +384,22 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||||
|
|
||||||
class ClaimCommands(ClaimTestCase):
|
class ClaimCommands(ClaimTestCase):
|
||||||
|
|
||||||
|
async def test_claim_list_type_filtering(self):
|
||||||
|
await self.channel_create()
|
||||||
|
await self.stream_create()
|
||||||
|
|
||||||
|
r = await self.claim_list(claim_type='channel')
|
||||||
|
self.assertEqual(1, len(r))
|
||||||
|
self.assertEqual('channel', r[0]['value_type'])
|
||||||
|
|
||||||
|
r = await self.claim_list(claim_type='stream')
|
||||||
|
self.assertEqual(1, len(r))
|
||||||
|
self.assertEqual('stream', r[0]['value_type'])
|
||||||
|
|
||||||
|
r = await self.claim_list(claim_type=['stream', 'channel'])
|
||||||
|
self.assertEqual(2, len(r))
|
||||||
|
self.assertEqual({'stream', 'channel'}, {c['value_type'] for c in r})
|
||||||
|
|
||||||
async def test_claim_stream_channel_list_with_resolve(self):
|
async def test_claim_stream_channel_list_with_resolve(self):
|
||||||
await self.channel_create()
|
await self.channel_create()
|
||||||
await self.stream_create()
|
await self.stream_create()
|
||||||
|
|
Loading…
Reference in a new issue