test_order_by fixed
This commit is contained in:
parent
1971539369
commit
85cf19bb2d
4 changed files with 21 additions and 15 deletions
|
@ -234,19 +234,23 @@ def select_claims(cols: List = None, for_count=False, **constraints) -> Select:
|
|||
if 'claim_type' in constraints:
|
||||
claim_types = constraints.pop('claim_type')
|
||||
if isinstance(claim_types, str):
|
||||
claim_types = [claim_types]
|
||||
claim_types = {claim_types}
|
||||
if claim_types:
|
||||
constraints['claim_type__in'] = {
|
||||
TXO_TYPES[claim_type] for claim_type in claim_types
|
||||
}
|
||||
if 'stream_types' in constraints:
|
||||
stream_types = constraints.pop('stream_types')
|
||||
if 'stream_type' in constraints:
|
||||
stream_types = constraints.pop('stream_type')
|
||||
if isinstance(stream_types, str):
|
||||
stream_types = {stream_types}
|
||||
if stream_types:
|
||||
constraints['stream_type__in'] = {
|
||||
STREAM_TYPES[stream_type] for stream_type in stream_types
|
||||
}
|
||||
if 'media_types' in constraints:
|
||||
media_types = constraints.pop('media_types')
|
||||
if 'media_type' in constraints:
|
||||
media_types = constraints.pop('media_type')
|
||||
if isinstance(media_types, str):
|
||||
media_types = {media_types}
|
||||
if media_types:
|
||||
constraints['media_type__in'] = set(media_types)
|
||||
|
||||
|
|
|
@ -555,8 +555,8 @@ class BulkLoader:
|
|||
|
||||
if claim.is_stream:
|
||||
d['claim_type'] = TXO_TYPES['stream']
|
||||
d['stream_type'] = STREAM_TYPES[guess_stream_type(d['media_type'])]
|
||||
d['media_type'] = claim.stream.source.media_type
|
||||
d['stream_type'] = STREAM_TYPES[guess_stream_type(d['media_type'])]
|
||||
d['title'] = claim.stream.title.replace('\x00', '')
|
||||
d['description'] = claim.stream.description.replace('\x00', '')
|
||||
d['author'] = claim.stream.author.replace('\x00', '')
|
||||
|
|
|
@ -1593,6 +1593,8 @@ class API:
|
|||
claim_filter_dict["is_controlling"] = is_controlling
|
||||
if public_key_id is not None:
|
||||
claim_filter_dict["public_key_id"] = public_key_id
|
||||
if claim_type is not None:
|
||||
claim_filter_dict["claim_type"] = claim_type
|
||||
page_num = abs(pagination['page'] or 1)
|
||||
page_size = min(abs(pagination['page_size'] or DEFAULT_PAGE_SIZE), 50)
|
||||
claim_filter_dict.update(stream_filter_dict)
|
||||
|
|
|
@ -239,7 +239,7 @@ class ClaimSearchCommand(ClaimTestCase):
|
|||
await self.assertFindsClaims([claim4, claim3, claim2], all_tags=['abc'], any_tag=['def', 'ghi'])
|
||||
|
||||
async def test_order_by(self):
|
||||
height = self.ledger.sync.network.remote_height
|
||||
height = await self.api.block_tip()
|
||||
claims = [await self.stream_create(f'claim{i}') for i in range(5)]
|
||||
|
||||
await self.assertFindsClaims(claims, order_by=["^height"])
|
||||
|
@ -346,16 +346,16 @@ class ClaimSearchCommand(ClaimTestCase):
|
|||
await self.assertFindsClaims([repost], claim_type='repost')
|
||||
|
||||
# stream_type
|
||||
await self.assertFindsClaims([octet, unknown], stream_types=['binary'])
|
||||
await self.assertFindsClaims([video], stream_types=['video'])
|
||||
await self.assertFindsClaims([image], stream_types=['image'])
|
||||
await self.assertFindsClaims([image, video], stream_types=['video', 'image'])
|
||||
await self.assertFindsClaims([octet, unknown], stream_type=['binary'])
|
||||
await self.assertFindsClaims([video], stream_type=['video'])
|
||||
await self.assertFindsClaims([image], stream_type=['image'])
|
||||
await self.assertFindsClaims([image, video], stream_type=['video', 'image'])
|
||||
|
||||
# media_type
|
||||
await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])
|
||||
await self.assertFindsClaims([video], media_types=['video/mp4'])
|
||||
await self.assertFindsClaims([image], media_types=['image/png'])
|
||||
await self.assertFindsClaims([image, video], media_types=['video/mp4', 'image/png'])
|
||||
await self.assertFindsClaims([octet, unknown], media_type=['application/octet-stream'])
|
||||
await self.assertFindsClaims([video], media_type=['video/mp4'])
|
||||
await self.assertFindsClaims([image], media_type=['image/png'])
|
||||
await self.assertFindsClaims([image, video], media_type=['video/mp4', 'image/png'])
|
||||
|
||||
# duration
|
||||
await self.assertFindsClaim(video, duration='>14')
|
||||
|
|
Loading…
Add table
Reference in a new issue