diff options
| author | jvoisin | 2018-04-04 21:59:46 +0200 |
|---|---|---|
| committer | jvoisin | 2018-04-04 21:59:46 +0200 |
| commit | 4ee091d833b55932fec345cc7403ef3723ecbd2f (patch) | |
| tree | 988bd7f50cdf32e34ff4418246461032fee29af9 /tests | |
| parent | 1ad817566de019521f565f4a7542f91b97c8a7a4 (diff) | |
Improve get_meta in various ways
- Normalize the case
- Strip \00, \r, space and \n
- Flatten metadata lists
- Add tests for audio files
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_climat2.py | 24 | ||||
| -rw-r--r-- | tests/test_libmat2.py | 12 |
2 files changed, 30 insertions, 6 deletions
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 16f97a2..cf7a63b 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -43,3 +43,27 @@ class TestGetMeta(unittest.TestCase): | |||
| 43 | self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) | 43 | self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) |
| 44 | self.assertIn(b'creator: jvoisin', stdout) | 44 | self.assertIn(b'creator: jvoisin', stdout) |
| 45 | self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) | 45 | self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) |
| 46 | |||
| 47 | def test_mp3(self): | ||
| 48 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.mp3'], | ||
| 49 | stdout=subprocess.PIPE) | ||
| 50 | stdout, _ = proc.communicate() | ||
| 51 | self.assertIn(b'TALB: harmfull', stdout) | ||
| 52 | self.assertIn(b'COMM::: Thank you for using MAT !', stdout) | ||
| 53 | |||
| 54 | def test_flac(self): | ||
| 55 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.flac'], | ||
| 56 | stdout=subprocess.PIPE) | ||
| 57 | stdout, _ = proc.communicate() | ||
| 58 | self.assertIn(b'comments: Thank you for using MAT !', stdout) | ||
| 59 | self.assertIn(b'genre: Python', stdout) | ||
| 60 | self.assertIn(b'title: I am so', stdout) | ||
| 61 | |||
| 62 | def test_ogg(self): | ||
| 63 | proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.ogg'], | ||
| 64 | stdout=subprocess.PIPE) | ||
| 65 | stdout, _ = proc.communicate() | ||
| 66 | self.assertIn(b'comments: Thank you for using MAT !', stdout) | ||
| 67 | self.assertIn(b'genre: Python', stdout) | ||
| 68 | self.assertIn(b'i am a : various comment', stdout) | ||
| 69 | self.assertIn(b'artist: jvoisin', stdout) | ||
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 34eea49..c2864c6 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -43,17 +43,17 @@ class TestGetMeta(unittest.TestCase): | |||
| 43 | def test_mp3(self): | 43 | def test_mp3(self): |
| 44 | p = audio.MP3Parser('./tests/data/dirty.mp3') | 44 | p = audio.MP3Parser('./tests/data/dirty.mp3') |
| 45 | meta = p.get_meta() | 45 | meta = p.get_meta() |
| 46 | self.assertEqual(meta['TXXX:I am a '], ['various comment']) | 46 | self.assertEqual(meta['TXXX:I am a'], 'various comment') |
| 47 | 47 | ||
| 48 | def test_ogg(self): | 48 | def test_ogg(self): |
| 49 | p = audio.OGGParser('./tests/data/dirty.ogg') | 49 | p = audio.OGGParser('./tests/data/dirty.ogg') |
| 50 | meta = p.get_meta() | 50 | meta = p.get_meta() |
| 51 | self.assertEqual(meta['TITLE'], ['I am so']) | 51 | self.assertEqual(meta['title'], 'I am so') |
| 52 | 52 | ||
| 53 | def test_flac(self): | 53 | def test_flac(self): |
| 54 | p = audio.FLACParser('./tests/data/dirty.flac') | 54 | p = audio.FLACParser('./tests/data/dirty.flac') |
| 55 | meta = p.get_meta() | 55 | meta = p.get_meta() |
| 56 | self.assertEqual(meta['TITLE'], ['I am so']) | 56 | self.assertEqual(meta['title'], 'I am so') |
| 57 | 57 | ||
| 58 | def test_docx(self): | 58 | def test_docx(self): |
| 59 | p = office.MSOfficeParser('./tests/data/dirty.docx') | 59 | p = office.MSOfficeParser('./tests/data/dirty.docx') |
| @@ -184,7 +184,7 @@ class TestCleaning(unittest.TestCase): | |||
| 184 | p = audio.MP3Parser('./tests/data/clean.mp3') | 184 | p = audio.MP3Parser('./tests/data/clean.mp3') |
| 185 | 185 | ||
| 186 | meta = p.get_meta() | 186 | meta = p.get_meta() |
| 187 | self.assertEqual(meta['TXXX:I am a '], ['various comment']) | 187 | self.assertEqual(meta['TXXX:I am a'], 'various comment') |
| 188 | 188 | ||
| 189 | ret = p.remove_all() | 189 | ret = p.remove_all() |
| 190 | self.assertTrue(ret) | 190 | self.assertTrue(ret) |
| @@ -199,7 +199,7 @@ class TestCleaning(unittest.TestCase): | |||
| 199 | p = audio.OGGParser('./tests/data/clean.ogg') | 199 | p = audio.OGGParser('./tests/data/clean.ogg') |
| 200 | 200 | ||
| 201 | meta = p.get_meta() | 201 | meta = p.get_meta() |
| 202 | self.assertEqual(meta['TITLE'], ['I am so']) | 202 | self.assertEqual(meta['title'], 'I am so') |
| 203 | 203 | ||
| 204 | ret = p.remove_all() | 204 | ret = p.remove_all() |
| 205 | self.assertTrue(ret) | 205 | self.assertTrue(ret) |
| @@ -214,7 +214,7 @@ class TestCleaning(unittest.TestCase): | |||
| 214 | p = audio.FLACParser('./tests/data/clean.flac') | 214 | p = audio.FLACParser('./tests/data/clean.flac') |
| 215 | 215 | ||
| 216 | meta = p.get_meta() | 216 | meta = p.get_meta() |
| 217 | self.assertEqual(meta['TITLE'], ['I am so']) | 217 | self.assertEqual(meta['title'], 'I am so') |
| 218 | 218 | ||
| 219 | ret = p.remove_all() | 219 | ret = p.remove_all() |
| 220 | self.assertTrue(ret) | 220 | self.assertTrue(ret) |
