49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
|
from .testcase import CommandTestCase
|
||
|
|
||
|
|
||
|
class ResolveCommand(CommandTestCase):
|
||
|
|
||
|
async def test_resolve(self):
|
||
|
await self.make_channel('@abc', '0.01')
|
||
|
|
||
|
# resolving a channel @abc
|
||
|
response = await self.resolve('lbry://@abc')
|
||
|
self.assertSetEqual({'lbry://@abc'}, set(response))
|
||
|
self.assertIn('certificate', response['lbry://@abc'])
|
||
|
self.assertNotIn('claim', response['lbry://@abc'])
|
||
|
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
|
||
|
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 0)
|
||
|
|
||
|
await self.make_claim('foo', '0.01', channel_name='@abc')
|
||
|
await self.make_claim('foo2', '0.01', channel_name='@abc')
|
||
|
|
||
|
# resolving a channel @abc with some claims in it
|
||
|
response = await self.resolve('lbry://@abc')
|
||
|
self.assertSetEqual({'lbry://@abc'}, set(response))
|
||
|
self.assertIn('certificate', response['lbry://@abc'])
|
||
|
self.assertNotIn('claim', response['lbry://@abc'])
|
||
|
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
|
||
|
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 2)
|
||
|
|
||
|
# resolving claim foo within channel @abc
|
||
|
response = await self.resolve('lbry://@abc/foo')
|
||
|
self.assertSetEqual({'lbry://@abc/foo'}, set(response))
|
||
|
claim = response['lbry://@abc/foo']
|
||
|
self.assertIn('certificate', claim)
|
||
|
self.assertIn('claim', claim)
|
||
|
self.assertEqual(claim['claim']['name'], 'foo')
|
||
|
self.assertEqual(claim['claim']['channel_name'], '@abc')
|
||
|
self.assertEqual(claim['certificate']['name'], '@abc')
|
||
|
self.assertEqual(claim['claims_in_channel'], 0)
|
||
|
|
||
|
# resolving claim foo by itself
|
||
|
response = await self.resolve('lbry://foo')
|
||
|
self.assertSetEqual({'lbry://foo'}, set(response))
|
||
|
claim = response['lbry://foo']
|
||
|
self.assertIn('certificate', claim)
|
||
|
self.assertIn('claim', claim)
|
||
|
self.assertEqual(claim['claim']['name'], 'foo')
|
||
|
self.assertEqual(claim['claim']['channel_name'], '@abc')
|
||
|
self.assertEqual(claim['certificate']['name'], '@abc')
|
||
|
self.assertEqual(claim['claims_in_channel'], 0)
|