File: test_writeback_audio.py

package info (click to toggle)
tracker-miners 3.8.2-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 16,656 kB
  • sloc: ansic: 59,413; python: 3,774; xml: 261; perl: 106; sh: 62; makefile: 53
file content (64 lines) | stat: -rw-r--r-- 2,143 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (C) 2019-2020, 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

import fixtures

import gi
from gi.repository import GLib


class WritebackAudioTest(fixtures.TrackerWritebackTest):
    def _writeback_test(self, path):
        prop = "nie:title"

        path = self.prepare_test_audio(self.datadir_path(path))
        initial_mtime = path.stat().st_mtime

        TEST_VALUE = prop.replace(":", "") + "test"

        self.writeback_data(
            {
                "rdf:type": GLib.Variant("s", "nfo:Audio"),
                "nie:isStoredAs": GLib.Variant("s", path.as_uri()),
                "nie:title": GLib.Variant("s", TEST_VALUE),
            }
        )

        self.wait_for_file_change(path, initial_mtime)

        results = fixtures.get_tracker_extract_output({}, path, output_format="json-ld")
        file_data = results["@graph"][0]
        self.assertIn(TEST_VALUE, file_data[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__":
    fixtures.tracker_test_main()