From 75d1fa585c80a94aae62c6a5d31a9a4d4dffc703 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 15 Aug 2016 18:30:14 -0400 Subject: [PATCH] fix tests --- lbrynet/core/LBRYMetadata.py | 2 +- tests/lbrynet/core/test_LBRYMetadata.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lbrynet/core/LBRYMetadata.py b/lbrynet/core/LBRYMetadata.py index 33b5e3a5c..a4c2b4fbc 100644 --- a/lbrynet/core/LBRYMetadata.py +++ b/lbrynet/core/LBRYMetadata.py @@ -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), ] diff --git a/tests/lbrynet/core/test_LBRYMetadata.py b/tests/lbrynet/core/test_LBRYMetadata.py index 4a64cfea6..953b8221f 100644 --- a/tests/lbrynet/core/test_LBRYMetadata.py +++ b/tests/lbrynet/core/test_LBRYMetadata.py @@ -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 = {