fix tests

This commit is contained in:
Jack 2016-08-15 18:30:14 -04:00
parent 072ff4b02e
commit 75d1fa585c
2 changed files with 16 additions and 4 deletions

View file

@ -323,7 +323,7 @@ class Metadata(Validator):
]
MIGRATE_MV002_TO_MV003 = [
(Validator.IF_VAL, 'ver', MV002, (Validator.UPDATE, 'content-type', 'content_type'), Validator.DO_NOTHING),
(Validator.IF_KEY, 'content-type', (Validator.UPDATE, 'content-type', 'content_type'), Validator.DO_NOTHING),
(Validator.IF_VAL, 'ver', MV002, (Validator.LOAD, 'ver', MV003), Validator.DO_NOTHING),
]

View file

@ -3,11 +3,24 @@ from twisted.trial import unittest
class MetadataTest(unittest.TestCase):
def test_assertion_if_source_is_missing(self):
def test_assertion_if_no_metadata(self):
metadata = {}
with self.assertRaises(AssertionError):
LBRYMetadata.Metadata(metadata)
def test_assertion_if_source_is_missing(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',
'content-type': 'audio/mpeg',
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
}
with self.assertRaises(AssertionError):
LBRYMetadata.Metadata(metadata)
def test_metadata_works_without_fee(self):
metadata = {
'license': 'Oscilloscope Laboratories',
@ -81,9 +94,8 @@ class MetadataTest(unittest.TestCase):
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
'MYSTERYFIELD': '?'
}
m = LBRYMetadata.Metadata(metadata, process_now=False)
with self.assertRaises(AssertionError):
LBRYMetadata.Metadata(metadata)
LBRYMetadata.Metadata(metadata, process_now=False)
def test_version_is_002_if_all_fields_are_present(self):
metadata = {