From 5d875c5020a5122b05635dd9c1da3e4a7f56a703 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Thu, 19 Jul 2012 18:18:28 -0400 Subject: [PATCH] cc-4105: Added tests for metadata handling --- .../media-monitor2/tests/test_metadata.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 python_apps/media-monitor2/tests/test_metadata.py diff --git a/python_apps/media-monitor2/tests/test_metadata.py b/python_apps/media-monitor2/tests/test_metadata.py new file mode 100644 index 000000000..c01d37a79 --- /dev/null +++ b/python_apps/media-monitor2/tests/test_metadata.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import os +import unittest +import sys +from media.monitor.metadata import Metadata + +class TestMetadata(unittest.TestCase): + def setUp(self): + self.music_folder = '/home/rudi/music' + + def test_got_music_folder(self): + t = os.path.exists(self.music_folder) + self.assertTrue(t) + if not t: + print("'%s' must exist for this test to run." % self.music_folder ) + sys.exit(1) + + def test_metadata(self): + full_paths = (os.path.join(self.music_folder,filename) for filename in os.listdir(self.music_folder)) + i = 0 + for full_path in full_paths: + if os.path.isfile(full_path): + md = Metadata(full_path).extract() + if i < 3: + i += 1 + print("Sample metadata: '%s'" % md) + self.assertTrue( len( md.keys() ) > 0 ) + self.assertTrue( 'MDATA_KEY_MD5' in md ) + else: + print("Skipping '%s'" % full_path) + +if __name__ == '__main__': unittest.main()