cc-4105: metadata is almost covered with tests
This commit is contained in:
parent
c5df7d8217
commit
4525bd5e4c
|
@ -2,7 +2,7 @@
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
from media.monitor.metadata import Metadata
|
import media.monitor.metadata as mmm
|
||||||
|
|
||||||
class TestMetadata(unittest.TestCase):
|
class TestMetadata(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -20,7 +20,7 @@ class TestMetadata(unittest.TestCase):
|
||||||
i = 0
|
i = 0
|
||||||
for full_path in full_paths:
|
for full_path in full_paths:
|
||||||
if os.path.isfile(full_path):
|
if os.path.isfile(full_path):
|
||||||
md_full = Metadata(full_path)
|
md_full = mmm.Metadata(full_path)
|
||||||
md = md_full.extract()
|
md = md_full.extract()
|
||||||
if i < 3:
|
if i < 3:
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -33,4 +33,18 @@ class TestMetadata(unittest.TestCase):
|
||||||
self.assertEqual( utf8[k].decode('utf-8'), md[k] )
|
self.assertEqual( utf8[k].decode('utf-8'), md[k] )
|
||||||
else: print("Skipping '%s' because it's a directory" % full_path)
|
else: print("Skipping '%s' because it's a directory" % full_path)
|
||||||
|
|
||||||
|
def test_airtime_mutagen_dict(self):
|
||||||
|
for muta,airtime in mmm.mutagen2airtime.iteritems():
|
||||||
|
self.assertEqual( mmm.airtime2mutagen[airtime], muta )
|
||||||
|
|
||||||
|
def test_format_length(self):
|
||||||
|
x1 = 123456
|
||||||
|
print("Formatting '%s' to '%s'" % (x1, mmm.format_length(x1)))
|
||||||
|
|
||||||
|
def test_truncate_to_length(self):
|
||||||
|
s1 = "testing with non string literal"
|
||||||
|
s2 = u"testing with unicode literal"
|
||||||
|
self.assertEqual( len(mmm.truncate_to_length(s1, 5)), 5)
|
||||||
|
self.assertEqual( len(mmm.truncate_to_length(s2, 8)), 8)
|
||||||
|
|
||||||
if __name__ == '__main__': unittest.main()
|
if __name__ == '__main__': unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue