summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjvoisin2018-03-25 16:17:41 +0200
committerjvoisin2018-03-25 16:17:41 +0200
commit19a8fd97aa44e2f42a933f43cc9852d6303d7ca6 (patch)
tree0b9535609a9c0c7c865fae7e717a6f7f19c8b4e3 /tests
parent4fa490d941cd0a1743963c4a8cfe89faeab6aded (diff)
Implement mp3 and ogg support
Diffstat (limited to 'tests')
-rw-r--r--tests/data/dirty.mp3bin0 -> 33646 bytes
-rw-r--r--tests/data/dirty.oggbin0 -> 23298 bytes
-rw-r--r--tests/test_libmat2.py44
3 files changed, 42 insertions, 2 deletions
diff --git a/tests/data/dirty.mp3 b/tests/data/dirty.mp3
new file mode 100644
index 0000000..7b6de6a
--- /dev/null
+++ b/tests/data/dirty.mp3
Binary files differ
diff --git a/tests/data/dirty.ogg b/tests/data/dirty.ogg
new file mode 100644
index 0000000..b938099
--- /dev/null
+++ b/tests/data/dirty.ogg
Binary files differ
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 1d31695..50a9a97 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -5,7 +5,7 @@ import shutil
5import os 5import os
6 6
7from src import parsers 7from src import parsers
8from src.parsers import pdf, png, jpg 8from src.parsers import pdf, png, jpg, audio
9 9
10class TestGetMeta(unittest.TestCase): 10class TestGetMeta(unittest.TestCase):
11 def test_pdf(self): 11 def test_pdf(self):
@@ -25,6 +25,17 @@ class TestGetMeta(unittest.TestCase):
25 meta = p.get_meta() 25 meta = p.get_meta()
26 self.assertEqual(meta['Comment'], 'Created with GIMP') 26 self.assertEqual(meta['Comment'], 'Created with GIMP')
27 27
28 def test_mp3(self):
29 p = audio.MP3Parser('./tests/data/dirty.mp3')
30 meta = p.get_meta()
31 self.assertEqual(meta['TXXX:I am a '], ['various comment'])
32
33 def test_ogg(self):
34 p = audio.OGGParser('./tests/data/dirty.ogg')
35 meta = p.get_meta()
36 self.assertEqual(meta['TITLE'], ['I am so'])
37
38
28class TestCleaning(unittest.TestCase): 39class TestCleaning(unittest.TestCase):
29 def test_pdf(self): 40 def test_pdf(self):
30 shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf') 41 shutil.copy('./tests/data/dirty.pdf', './tests/data/clean.pdf')
@@ -57,7 +68,6 @@ class TestCleaning(unittest.TestCase):
57 68
58 os.remove('./tests/data/clean.png') 69 os.remove('./tests/data/clean.png')
59 70
60
61 def test_jpg(self): 71 def test_jpg(self):
62 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') 72 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')
63 p = jpg.JPGParser('./tests/data/clean.jpg') 73 p = jpg.JPGParser('./tests/data/clean.jpg')
@@ -72,3 +82,33 @@ class TestCleaning(unittest.TestCase):
72 self.assertEqual(p.get_meta(), {}) 82 self.assertEqual(p.get_meta(), {})
73 83
74 os.remove('./tests/data/clean.jpg') 84 os.remove('./tests/data/clean.jpg')
85
86 def test_mp3(self):
87 shutil.copy('./tests/data/dirty.mp3', './tests/data/clean.mp3')
88 p = audio.MP3Parser('./tests/data/clean.mp3')
89
90 meta = p.get_meta()
91 self.assertEqual(meta['TXXX:I am a '], ['various comment'])
92
93 ret = p.remove_all()
94 self.assertTrue(ret)
95
96 p = audio.MP3Parser('./tests/data/clean.mp3.cleaned')
97 self.assertEqual(p.get_meta(), {})
98
99 os.remove('./tests/data/clean.mp3')
100
101 def test_ogg(self):
102 shutil.copy('./tests/data/dirty.ogg', './tests/data/clean.ogg')
103 p = audio.OGGParser('./tests/data/clean.ogg')
104
105 meta = p.get_meta()
106 self.assertEqual(meta['TITLE'], ['I am so'])
107
108 ret = p.remove_all()
109 self.assertTrue(ret)
110
111 p = audio.OGGParser('./tests/data/clean.ogg.cleaned')
112 self.assertEqual(p.get_meta(), {})
113
114 os.remove('./tests/data/clean.ogg')