-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_mp3.py
33 lines (25 loc) · 1.23 KB
/
test_mp3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from unittest import TestCase
from polydet import PolyglotLevel
from polydet.plugins import mp3
class TestMP3Detector(TestCase):
def test_regular_file(self):
self.assertEqual(PolyglotLevel(),
mp3.check('tests/samples/mp3/regular.mp3'))
def test_not_mp3(self):
self.assertIsNone(mp3.check('tests/samples/zip/regular.zip'))
def test_garbage_at_beginning(self):
result = mp3.check('tests/samples/mp3/garbage_at_beginning.mp3')
self.assertEqual(PolyglotLevel(suspicious_chunks=[(0, 0x1AC)]),
result)
def test_garbage_in_middle(self):
result = mp3.check('tests/samples/mp3/garbage_in_middle.mp3')
self.assertEqual(PolyglotLevel(suspicious_chunks=[(0x1AC, 0xF50)]),
result)
def test_garbage_at_end(self):
result = mp3.check('tests/samples/mp3/garbage_at_end.mp3')
self.assertEqual(PolyglotLevel(suspicious_chunks=[(0x6C616, 0xB4)]),
result)
def test_fake(self):
self.assertIsNone(mp3.check('tests/samples/mp3/fake1.mp3'))
self.assertIsNone(mp3.check('tests/samples/mp3/fake2.mp3'))
self.assertIsNone(mp3.check('tests/samples/mp3/fake3.mp3'))