bug fix: check if fee is in metadata before loading

This commit is contained in:
Job Evers-Meltzer 2016-07-28 09:42:16 -05:00
parent 67c5d15f51
commit 295e427abe
2 changed files with 16 additions and 1 deletions

View file

@ -89,7 +89,7 @@ class Metadata(dict):
self.update({k: metadata.pop(k)})
for k in METADATA_REVISIONS[version]['optional']:
if k == 'fee':
self['fee'] = LBRYFeeValidator(metadata.pop('fee'))
self._load_fee(metadata)
elif k in metadata:
self.update({k: metadata.pop(k)})

View file

@ -44,6 +44,21 @@ class MetadataTest(unittest.TestCase):
with self.assertRaises(AssertionError):
LBRYMetadata.Metadata(metadata)
def test_metadata_works_without_fee(self):
metadata = {
'license': 'Oscilloscope Laboratories',
'description': 'Four couples meet for Sunday brunch only to discover they are stuck in a house together as the world may be about to end.',
'language': 'en',
'title': "It's a Disaster",
'author': 'Written and directed by Todd Berger',
'sources': {
'lbry_sd_hash': '8d0d6ea64d09f5aa90faf5807d8a761c32a27047861e06f81f41e35623a348a4b0104052161d5f89cf190f9672bc4ead'},
'content-type': 'audio/mpeg',
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg'
}
m = LBRYMetadata.Metadata(metadata)
self.assertFalse('key' in m)
def test_assertion_if_invalid_source(self):
metadata = {
'license': 'Oscilloscope Laboratories',