python: add movie metadata parsing test
authorOlivier Aubert <contact@olivieraubert.net>
Sat, 6 Oct 2018 22:06:29 +0000 (00:06 +0200)
committerOlivier Aubert <contact@olivieraubert.net>
Sat, 6 Oct 2018 22:06:29 +0000 (00:06 +0200)
tests/samples/README [new file with mode: 0644]
tests/samples/sample.mp4 [new file with mode: 0644]
tests/test.py

diff --git a/tests/samples/README b/tests/samples/README
new file mode 100644 (file)
index 0000000..1f62939
--- /dev/null
@@ -0,0 +1,3 @@
+These sample files are used in tests.
+
+They were downloaded from http://techslides.com/sample-files-for-development
diff --git a/tests/samples/sample.mp4 b/tests/samples/sample.mp4
new file mode 100644 (file)
index 0000000..1fc4788
Binary files /dev/null and b/tests/samples/sample.mp4 differ
index d958114..e8d088b 100755 (executable)
@@ -26,6 +26,7 @@
 """Unittest module.
 """
 
+import os
 import unittest
 try:
     import urllib.parse as urllib # python3
@@ -37,6 +38,7 @@ try:
 except ImportError:
     import generated.vlc as vlc
 
+SAMPLE = os.path.join(os.path.dirname(__file__), 'samples/sample.mp4')
 print ("Checking " + vlc.__file__)
 
 class TestVLCAPI(unittest.TestCase):
@@ -130,11 +132,20 @@ class TestVLCAPI(unittest.TestCase):
             except TypeError:
                 print("vlc.libvlc_log_get_context(ctx)")
 
-        url = '/tmp/foo.mp4'
-
         instance = vlc.Instance('--vout dummy --aout dummy')
         instance.log_set(log_handler, None)
         player = instance.media_player_new()
 
+    def test_tracks_get(self):
+        self.assertTrue(os.path.exists(SAMPLE))
+        m = vlc.Media(SAMPLE)
+        m.parse()
+        # Audiotrack is the second one
+        audiotrack = list(m.tracks_get())[1]
+        self.assertEqual(audiotrack.language, b"eng")
+        self.assertEqual(audiotrack.description, b"Stereo")
+        self.assertEqual(audiotrack.bitrate, 83051)
+        self.assertEqual(m.get_duration(), 5568)
+
 if __name__ == '__main__':
     unittest.main()