forked from LBRYCommunity/lbry-sdk
remove url sequence feature from code and tests
This commit is contained in:
parent
c8466afac2
commit
912065a121
2 changed files with 2 additions and 15 deletions
|
@ -23,7 +23,6 @@ def _create_url_regex():
|
||||||
_named(name+"_name", prefix + invalid_names_regex) +
|
_named(name+"_name", prefix + invalid_names_regex) +
|
||||||
_oneof(
|
_oneof(
|
||||||
_group('[:#]' + _named(name+"_claim_id", "[0-9a-f]{1,40}")),
|
_group('[:#]' + _named(name+"_claim_id", "[0-9a-f]{1,40}")),
|
||||||
_group(r'\*' + _named(name+"_sequence", '[1-9][0-9]*')),
|
|
||||||
_group(r'\$' + _named(name+"_amount_order", '[1-9][0-9]*'))
|
_group(r'\$' + _named(name+"_amount_order", '[1-9][0-9]*'))
|
||||||
) + '?'
|
) + '?'
|
||||||
)
|
)
|
||||||
|
@ -50,7 +49,6 @@ def normalize_name(name):
|
||||||
class PathSegment(NamedTuple):
|
class PathSegment(NamedTuple):
|
||||||
name: str
|
name: str
|
||||||
claim_id: str = None
|
claim_id: str = None
|
||||||
sequence: int = None
|
|
||||||
amount_order: int = None
|
amount_order: int = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -61,8 +59,6 @@ class PathSegment(NamedTuple):
|
||||||
q = {'name': self.name}
|
q = {'name': self.name}
|
||||||
if self.claim_id is not None:
|
if self.claim_id is not None:
|
||||||
q['claim_id'] = self.claim_id
|
q['claim_id'] = self.claim_id
|
||||||
if self.sequence is not None:
|
|
||||||
q['sequence'] = self.sequence
|
|
||||||
if self.amount_order is not None:
|
if self.amount_order is not None:
|
||||||
q['amount_order'] = self.amount_order
|
q['amount_order'] = self.amount_order
|
||||||
return q
|
return q
|
||||||
|
@ -70,8 +66,6 @@ class PathSegment(NamedTuple):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.claim_id is not None:
|
if self.claim_id is not None:
|
||||||
return f"{self.name}:{self.claim_id}"
|
return f"{self.name}:{self.claim_id}"
|
||||||
elif self.sequence is not None:
|
|
||||||
return f"{self.name}*{self.sequence}"
|
|
||||||
elif self.amount_order is not None:
|
elif self.amount_order is not None:
|
||||||
return f"{self.name}${self.amount_order}"
|
return f"{self.name}${self.amount_order}"
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -118,7 +112,6 @@ class URL(NamedTuple):
|
||||||
segments[segment] = PathSegment(
|
segments[segment] = PathSegment(
|
||||||
parts[f'{segment}_name'],
|
parts[f'{segment}_name'],
|
||||||
parts[f'{segment}_claim_id'],
|
parts[f'{segment}_claim_id'],
|
||||||
parts[f'{segment}_sequence'],
|
|
||||||
parts[f'{segment}_amount_order']
|
parts[f'{segment}_amount_order']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ claim_id = "63f2da17b0d90042c559cc73b6b17f853945c43e"
|
||||||
class TestURLParsing(unittest.TestCase):
|
class TestURLParsing(unittest.TestCase):
|
||||||
|
|
||||||
segments = 'stream', 'channel'
|
segments = 'stream', 'channel'
|
||||||
fields = 'name', 'claim_id', 'sequence', 'amount_order'
|
fields = 'name', 'claim_id', 'amount_order'
|
||||||
|
|
||||||
def _assert_url(self, url_string, strictly=True, **kwargs):
|
def _assert_url(self, url_string, strictly=True, **kwargs):
|
||||||
url = URL.parse(url_string)
|
url = URL.parse(url_string)
|
||||||
|
@ -43,25 +43,22 @@ class TestURLParsing(unittest.TestCase):
|
||||||
url = self._assert_url
|
url = self._assert_url
|
||||||
# stream
|
# stream
|
||||||
url('test', stream_name='test')
|
url('test', stream_name='test')
|
||||||
url('test*1', stream_name='test', stream_sequence='1')
|
url('test*1', stream_name='test*1')
|
||||||
url('test$1', stream_name='test', stream_amount_order='1')
|
url('test$1', stream_name='test', stream_amount_order='1')
|
||||||
url(f'test#{claim_id}', stream_name='test', stream_claim_id=claim_id, strictly=False)
|
url(f'test#{claim_id}', stream_name='test', stream_claim_id=claim_id, strictly=False)
|
||||||
url(f'test:{claim_id}', stream_name='test', stream_claim_id=claim_id)
|
url(f'test:{claim_id}', stream_name='test', stream_claim_id=claim_id)
|
||||||
# channel
|
# channel
|
||||||
url('@test', channel_name='@test')
|
url('@test', channel_name='@test')
|
||||||
url('@test*1', channel_name='@test', channel_sequence='1')
|
|
||||||
url('@test$1', channel_name='@test', channel_amount_order='1')
|
url('@test$1', channel_name='@test', channel_amount_order='1')
|
||||||
url(f'@test#{claim_id}', channel_name='@test', channel_claim_id=claim_id, strictly=False)
|
url(f'@test#{claim_id}', channel_name='@test', channel_claim_id=claim_id, strictly=False)
|
||||||
url(f'@test:{claim_id}', channel_name='@test', channel_claim_id=claim_id)
|
url(f'@test:{claim_id}', channel_name='@test', channel_claim_id=claim_id)
|
||||||
# channel/stream
|
# channel/stream
|
||||||
url('lbry://@test/stuff', channel_name='@test', stream_name='stuff')
|
url('lbry://@test/stuff', channel_name='@test', stream_name='stuff')
|
||||||
url('lbry://@test*1/stuff', channel_name='@test', channel_sequence='1', stream_name='stuff')
|
|
||||||
url('lbry://@test$1/stuff', channel_name='@test', channel_amount_order='1', stream_name='stuff')
|
url('lbry://@test$1/stuff', channel_name='@test', channel_amount_order='1', stream_name='stuff')
|
||||||
url(f'lbry://@test#{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff', strictly=False)
|
url(f'lbry://@test#{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff', strictly=False)
|
||||||
url(f'lbry://@test:{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff')
|
url(f'lbry://@test:{claim_id}/stuff', channel_name='@test', channel_claim_id=claim_id, stream_name='stuff')
|
||||||
# combined legacy and new
|
# combined legacy and new
|
||||||
url('@test:1/stuff#2', channel_claim_id='1', stream_claim_id='2', channel_name='@test', stream_name='stuff', strictly=False)
|
url('@test:1/stuff#2', channel_claim_id='1', stream_claim_id='2', channel_name='@test', stream_name='stuff', strictly=False)
|
||||||
url('@test*1/stuff#2', channel_sequence='1', stream_claim_id='2', channel_name='@test', stream_name='stuff', strictly=False)
|
|
||||||
# unicode regex edges
|
# unicode regex edges
|
||||||
_url = lambda name: url(name, stream_name=name)
|
_url = lambda name: url(name, stream_name=name)
|
||||||
_url('\uD799')
|
_url('\uD799')
|
||||||
|
@ -111,10 +108,8 @@ class TestURLParsing(unittest.TestCase):
|
||||||
fail("lbry://test@")
|
fail("lbry://test@")
|
||||||
fail("lbry://tes@t")
|
fail("lbry://tes@t")
|
||||||
fail(f"lbry://test:1#{claim_id}")
|
fail(f"lbry://test:1#{claim_id}")
|
||||||
fail("lbry://test*0")
|
|
||||||
fail("lbry://test$0")
|
fail("lbry://test$0")
|
||||||
fail("lbry://test/path")
|
fail("lbry://test/path")
|
||||||
fail("lbry://@test1*1ab/fakepath")
|
|
||||||
fail("lbry://test:1:1:1")
|
fail("lbry://test:1:1:1")
|
||||||
fail("whatever/lbry://test")
|
fail("whatever/lbry://test")
|
||||||
fail("lbry://lbry://test")
|
fail("lbry://lbry://test")
|
||||||
|
@ -122,5 +117,4 @@ class TestURLParsing(unittest.TestCase):
|
||||||
fail("lbry://abc:0x123")
|
fail("lbry://abc:0x123")
|
||||||
fail("lbry://abc:0x123/page")
|
fail("lbry://abc:0x123/page")
|
||||||
fail("lbry://@test1#ABCDEF/fakepath")
|
fail("lbry://@test1#ABCDEF/fakepath")
|
||||||
fail("test*0001")
|
|
||||||
fail("lbry://@test1$1/fakepath?arg1&arg2&arg3")
|
fail("lbry://@test1$1/fakepath?arg1&arg2&arg3")
|
||||||
|
|
Loading…
Reference in a new issue