[tracker-miners/wip/jfelder/audio-writeback: 8/8] functional-tests: Add tests for audio writeback module



commit 81023da185781a2ba9c08ae3247677a582182bae
Author: Sam Thursfield <sam afuera me uk>
Date:   Mon Jul 8 17:23:01 2019 +0100

    functional-tests: Add tests for audio writeback module
    
    So far these only test writeback of one property (nie:title), but this
    is a big improvement over testing nothing at all.

 tests/functional-tests/502-writeback-audio.py      |  61 +++++++++++++++++++++
 tests/functional-tests/meson.build                 |   1 +
 .../test-writeback-data/writeback-test-5.mp3       | Bin 0 -> 49153 bytes
 .../test-writeback-data/writeback-test-6.ogg       | Bin 0 -> 78716 bytes
 .../test-writeback-data/writeback-test-7.flac      | Bin 0 -> 20274 bytes
 .../test-writeback-data/writeback-test-8.mp4       | Bin 0 -> 234051 bytes
 6 files changed, 62 insertions(+)
---
diff --git a/tests/functional-tests/502-writeback-audio.py b/tests/functional-tests/502-writeback-audio.py
new file mode 100755
index 000000000..f74ca4913
--- /dev/null
+++ b/tests/functional-tests/502-writeback-audio.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2019, Sam Thursfield (sam afuera me uk)
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA  02110-1301, USA.
+
+
+import unittest
+
+from common.utils.extractor import get_tracker_extract_jsonld_output
+from common.utils.helpers import log
+from common.utils.writebacktest import CommonTrackerWritebackTest
+
+
+class WritebackAudioTest(CommonTrackerWritebackTest):
+    def _writeback_test(self, path):
+        prop = 'nie:title'
+
+        path = self.prepare_test_audio(path)
+        initial_mtime = path.stat().st_mtime
+
+        TEST_VALUE = prop.replace(":", "") + "test"
+        SPARQL_TMPL = """
+           DELETE { ?u %s ?v } WHERE { ?u nie:url '%s' ; %s ?v }
+           INSERT { ?u %s '%s' }
+           WHERE  { ?u nie:url '%s' }
+        """
+        self.tracker.update(SPARQL_TMPL % (prop, path.as_uri(), prop, prop, TEST_VALUE, path.as_uri()))
+
+        self.wait_for_file_change(path, initial_mtime)
+
+        results = get_tracker_extract_jsonld_output(path)
+        self.assertIn(TEST_VALUE, results[prop])
+
+    def test_writeback_mp3(self):
+        self._writeback_test(self.datadir_path('writeback-test-5.mp3'))
+
+    def test_writeback_ogg(self):
+        self._writeback_test(self.datadir_path('writeback-test-6.ogg'))
+
+    def test_writeback_flac(self):
+        self._writeback_test(self.datadir_path('writeback-test-7.flac'))
+
+    def test_writeback_aac(self):
+        self._writeback_test(self.datadir_path('writeback-test-8.mp4'))
+
+if __name__ == "__main__":
+    unittest.main(failfast=True)
diff --git a/tests/functional-tests/meson.build b/tests/functional-tests/meson.build
index be2d6476d..d3c4bd3ce 100644
--- a/tests/functional-tests/meson.build
+++ b/tests/functional-tests/meson.build
@@ -41,6 +41,7 @@ functional_tests = [
   '410-extractor-decorator',
   '500-writeback-images',
   '501-writeback-image-details',
+  '502-writeback-audio',
   '600-applications-camera',
   '601-applications-sync',
 ]
diff --git a/tests/functional-tests/test-writeback-data/writeback-test-5.mp3 
b/tests/functional-tests/test-writeback-data/writeback-test-5.mp3
new file mode 100644
index 000000000..b19e2e662
Binary files /dev/null and b/tests/functional-tests/test-writeback-data/writeback-test-5.mp3 differ
diff --git a/tests/functional-tests/test-writeback-data/writeback-test-6.ogg 
b/tests/functional-tests/test-writeback-data/writeback-test-6.ogg
new file mode 100644
index 000000000..98e26d9cf
Binary files /dev/null and b/tests/functional-tests/test-writeback-data/writeback-test-6.ogg differ
diff --git a/tests/functional-tests/test-writeback-data/writeback-test-7.flac 
b/tests/functional-tests/test-writeback-data/writeback-test-7.flac
new file mode 100644
index 000000000..88c7eb95d
Binary files /dev/null and b/tests/functional-tests/test-writeback-data/writeback-test-7.flac differ
diff --git a/tests/functional-tests/test-writeback-data/writeback-test-8.mp4 
b/tests/functional-tests/test-writeback-data/writeback-test-8.mp4
new file mode 100644
index 000000000..baf1dedc1
Binary files /dev/null and b/tests/functional-tests/test-writeback-data/writeback-test-8.mp4 differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]