def testJSONSerializationMetadata(self): from music21.musicxml import xmlHandler from music21.musicxml import fromMxObjects from music21.musicxml import testFiles from music21 import metadata md = metadata.Metadata( title='Concerto in F', date='2010', composer='Frank', ) #environLocal.printDebug([str(md.json)]) self.assertEqual(md.composer, 'Frank') #md.jsonPrint() mdNew = metadata.Metadata() jsonString = freezeThaw.JSONFreezer(md).json freezeThaw.JSONThawer(mdNew).json = jsonString self.assertEqual(mdNew.date, '2010/--/--') self.assertEqual(mdNew.composer, 'Frank') self.assertEqual(mdNew.title, 'Concerto in F') # test getting meta data from an imported source d = xmlHandler.Document() d.read(testFiles.mozartTrioK581Excerpt) # @UndefinedVariable mxScore = d.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.movementNumber, '3') self.assertEqual( md.movementName, 'Menuetto (Excerpt from Second Trio)') self.assertEqual(md.title, 'Quintet for Clarinet and Strings') self.assertEqual(md.number, 'K. 581') self.assertEqual(md.composer, 'Wolfgang Amadeus Mozart') # convert to json and see if data is still there #md.jsonPrint() mdNew = metadata.Metadata() jsonString = freezeThaw.JSONFreezer(md).json freezeThaw.JSONThawer(mdNew).json = jsonString self.assertEqual(mdNew.movementNumber, '3') self.assertEqual( mdNew.movementName, 'Menuetto (Excerpt from Second Trio)') self.assertEqual(mdNew.title, 'Quintet for Clarinet and Strings') self.assertEqual(mdNew.number, 'K. 581') self.assertEqual(mdNew.composer, 'Wolfgang Amadeus Mozart')
def testJSONSerializationMetadata(self): from music21.musicxml import xmlHandler from music21.musicxml import fromMxObjects from music21.musicxml import testFiles from music21 import metadata md = metadata.Metadata( title='Concerto in F', date='2010', composer='Frank', ) #environLocal.printDebug([str(md.json)]) self.assertEqual(md.composer, 'Frank') #md.jsonPrint() mdNew = metadata.Metadata() jsonString = freezeThaw.JSONFreezer(md).json freezeThaw.JSONThawer(mdNew).json = jsonString self.assertEqual(mdNew.date, '2010/--/--') self.assertEqual(mdNew.composer, 'Frank') self.assertEqual(mdNew.title, 'Concerto in F') # test getting meta data from an imported source d = xmlHandler.Document() d.read(testFiles.mozartTrioK581Excerpt) # @UndefinedVariable mxScore = d.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.movementNumber, '3') self.assertEqual(md.movementName, 'Menuetto (Excerpt from Second Trio)') self.assertEqual(md.title, 'Quintet for Clarinet and Strings') self.assertEqual(md.number, 'K. 581') self.assertEqual(md.composer, 'Wolfgang Amadeus Mozart') # convert to json and see if data is still there #md.jsonPrint() mdNew = metadata.Metadata() jsonString = freezeThaw.JSONFreezer(md).json freezeThaw.JSONThawer(mdNew).json = jsonString self.assertEqual(mdNew.movementNumber, '3') self.assertEqual(mdNew.movementName, 'Menuetto (Excerpt from Second Trio)') self.assertEqual(mdNew.title, 'Quintet for Clarinet and Strings') self.assertEqual(mdNew.number, 'K. 581') self.assertEqual(mdNew.composer, 'Wolfgang Amadeus Mozart')
def testMetadataLoadCorpus(self): from music21.musicxml import xmlHandler from music21.musicxml import testFiles as mTF from music21.musicxml import fromMxObjects document = xmlHandler.Document() document.read(mTF.mozartTrioK581Excerpt) # @UndefinedVariable mxScore = document.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.movementNumber, "3") self.assertEqual(md.movementName, "Menuetto (Excerpt from Second Trio)") self.assertEqual(md.title, "Quintet for Clarinet and Strings") self.assertEqual(md.number, "K. 581") # get contributors directly from Metadata interface self.assertEqual(md.composer, "Wolfgang Amadeus Mozart") document.read(mTF.binchoisMagnificat) # @UndefinedVariable mxScore = document.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.composer, "Gilles Binchois")
def testMetadataLoadCorpus(self): from music21.musicxml import xmlHandler from music21.musicxml import testFiles as mTF from music21.musicxml import fromMxObjects document = xmlHandler.Document() document.read(mTF.mozartTrioK581Excerpt) # @UndefinedVariable mxScore = document.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.movementNumber, '3') self.assertEqual(md.movementName, 'Menuetto (Excerpt from Second Trio)') self.assertEqual(md.title, 'Quintet for Clarinet and Strings') self.assertEqual(md.number, 'K. 581') # get contributors directly from Metadata interface self.assertEqual(md.composer, 'Wolfgang Amadeus Mozart') document.read(mTF.binchoisMagnificat) # @UndefinedVariable mxScore = document.score # get the mx score directly md = fromMxObjects.mxScoreToMetadata(mxScore) self.assertEqual(md.composer, 'Gilles Binchois')