summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2017-12-18 12:51:20 +0000
committerSam Thursfield <sam@afuera.me.uk>2017-12-18 16:42:54 +0000
commit5373cf2c93f39879603f1f27da7099c79797ce79 (patch)
tree96f91d90b64f2fc7276231d83eec3722f22c47aa /tests
parentd74a9bda65cd5da0413750a6a880780e011f0310 (diff)
downloadtracker-5373cf2c93f39879603f1f27da7099c79797ce79.tar.gz
functional-tests: Remove tests that belong in tracker-miners.git
Diffstat (limited to 'tests')
-rwxr-xr-xtests/functional-tests/300-miner-basic-ops.py312
-rwxr-xr-xtests/functional-tests/301-miner-resource-removal.py125
-rwxr-xr-xtests/functional-tests/310-fts-indexing.py334
-rwxr-xr-xtests/functional-tests/400-extractor-metadata.py256
-rwxr-xr-xtests/functional-tests/410-extractor-decorator.py107
-rwxr-xr-xtests/functional-tests/500-writeback.py184
-rwxr-xr-xtests/functional-tests/501-writeback-details.py107
-rwxr-xr-xtests/functional-tests/600-applications-camera.py286
-rwxr-xr-xtests/functional-tests/601-applications-sync.py122
-rw-r--r--tests/functional-tests/Makefile.am15
-rw-r--r--tests/functional-tests/meson.build9
-rw-r--r--tests/functional-tests/test-apps-data/Makefile.am8
-rw-r--r--tests/functional-tests/test-apps-data/test-image-1.jpgbin7558 -> 0 bytes
-rw-r--r--tests/functional-tests/test-apps-data/test-music-1.mp3bin61547 -> 0 bytes
-rw-r--r--tests/functional-tests/test-apps-data/test-video-1.mp4bin211931 -> 0 bytes
15 files changed, 1 insertions, 1864 deletions
diff --git a/tests/functional-tests/300-miner-basic-ops.py b/tests/functional-tests/300-miner-basic-ops.py
deleted file mode 100755
index cf4fb4747..000000000
--- a/tests/functional-tests/300-miner-basic-ops.py
+++ /dev/null
@@ -1,312 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2010, Nokia (ivan.frade@nokia.com)
-#
-# 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.
-
-#
-# TODO:
-# These tests are for files... we need to write them for folders!
-#
-"""
-Monitor a test directory and copy/move/remove/update files and folders there.
-Check the basic data of the files is updated accordingly in tracker.
-"""
-import os
-import shutil
-import time
-
-import unittest2 as ut
-from common.utils.helpers import log
-from common.utils.minertest import CommonTrackerMinerTest, MINER_TMP_DIR, uri, path
-
-class MinerCrawlTest (CommonTrackerMinerTest):
- """
- Test cases to check if miner is able to monitor files that are created, deleted or moved
- """
- def __get_text_documents (self):
- return self.tracker.query ("""
- SELECT ?url WHERE {
- ?u a nfo:TextDocument ;
- nie:url ?url.
- }
- """)
-
- def __get_parent_urn (self, filepath):
- result = self.tracker.query ("""
- SELECT nfo:belongsToContainer(?u) WHERE {
- ?u a nfo:FileDataObject ;
- nie:url \"%s\" .
- }
- """ % (uri (filepath)))
- self.assertEquals (len (result), 1)
- return result[0][0]
-
- def __get_file_urn (self, filepath):
- result = self.tracker.query ("""
- SELECT ?u WHERE {
- ?u a nfo:FileDataObject ;
- nie:url \"%s\" .
- }
- """ % (uri (filepath)))
- self.assertEquals (len (result), 1)
- return result[0][0]
-
- """
- Boot the miner with the correct configuration and check everything is fine
- """
- def test_01_initial_crawling (self):
- """
- The precreated files and folders should be there
- """
- # Maybe the information hasn't been committed yet
- time.sleep (1)
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 3)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
-
- # We don't check (yet) folders, because Applications module is injecting results
-
-
-## class copy(TestUpdate):
-## FIXME all tests in one class because the miner-fs restarting takes some time (~5 sec)
-## Maybe we can move the miner-fs initialization to setUpModule and then move these
-## tests to different classes
-
- def test_02_copy_from_unmonitored_to_monitored (self):
- """
- Copy an file from unmonitored directory to monitored directory
- and verify if data base is updated accordingly
- """
- source = os.path.join (MINER_TMP_DIR, "test-no-monitored", "file0.txt")
- dest = os.path.join (MINER_TMP_DIR, "test-monitored", "file0.txt")
- shutil.copyfile (source, dest)
-
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nfo:TextDocument', uri(dest))
-
- # verify if miner indexed this file.
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 4)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/file0.txt"), unpacked_result)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest)
- self.system.store.await_resource_deleted (dest_id)
-
- def test_03_copy_from_monitored_to_unmonitored (self):
- """
- Copy an file from a monitored location to an unmonitored location
- Nothing should change
- """
-
- # Copy from monitored to unmonitored
- source = os.path.join (MINER_TMP_DIR, "test-monitored", "file1.txt")
- dest = os.path.join (MINER_TMP_DIR, "test-no-monitored", "file1.txt")
- shutil.copyfile (source, dest)
-
- time.sleep (1)
- # Nothing changed
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 3, "Results:" + str(result))
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
-
- # Clean the file
- os.remove (dest)
-
- def test_04_copy_from_monitored_to_monitored (self):
- """
- Copy a file between monitored directories
- """
- source = os.path.join (MINER_TMP_DIR, "test-monitored", "file1.txt")
- dest = os.path.join (MINER_TMP_DIR, "test-monitored", "dir1", "dir2", "file-test04.txt")
- shutil.copyfile (source, dest)
-
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nfo:TextDocument', uri(dest))
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 4)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file-test04.txt"), unpacked_result)
-
- # Clean the file
- os.remove (dest)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
-
-
- def test_05_move_from_unmonitored_to_monitored (self):
- """
- Move a file from unmonitored to monitored directory
- """
- source = os.path.join (MINER_TMP_DIR, "test-no-monitored", "file0.txt")
- dest = os.path.join (MINER_TMP_DIR, "test-monitored", "dir1", "file-test05.txt")
- shutil.move (source, dest)
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nfo:TextDocument', uri(dest))
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 4)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/file-test05.txt"), unpacked_result)
-
- # Clean the file
- os.remove (dest)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
-
-## """ move operation and tracker-miner response test cases """
-## class move(TestUpdate):
-
-
- def test_06_move_from_monitored_to_unmonitored (self):
- """
- Move a file from monitored to unmonitored directory
- """
- source = path("test-monitored/dir1/file2.txt")
- dest = path("test-no-monitored/file2.txt")
- source_id = self.system.store.get_resource_id (uri(source))
- shutil.move (source, dest)
- self.system.store.await_resource_deleted (source_id)
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 2)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
-
- # Restore the file
- shutil.move (dest, source)
- self.system.store.await_resource_inserted ('nfo:TextDocument', uri(source))
- self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
-
-
- def test_07_move_from_monitored_to_monitored (self):
- """
- Move a file between monitored directories
- """
-
- source = path("test-monitored/dir1/file2.txt")
- dest = path("test-monitored/file2.txt")
-
- resource_id = self.tracker.get_resource_id(url=uri(source))
-
- source_dir_urn = self.__get_file_urn (os.path.dirname(source))
- parent_before = self.__get_parent_urn (source)
- self.assertEquals (source_dir_urn, parent_before)
-
- shutil.move (source, dest)
- self.tracker.await_property_changed(resource_id, 'nie:url')
-
- # Checking fix for NB#214413: After a move operation, nfo:belongsToContainer
- # should be changed to the new one
- dest_dir_urn = self.__get_file_urn (os.path.dirname(dest))
- parent_after = self.__get_parent_urn (dest)
- self.assertNotEquals (parent_before, parent_after)
- self.assertEquals (dest_dir_urn, parent_after)
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 3)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/file2.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
-
- # Restore the file
- shutil.move (dest, source)
- self.tracker.await_property_changed(resource_id, 'nie:url')
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 3)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), unpacked_result)
-
-
- def test_08_deletion_single_file (self):
- """
- Delete one of the files
- """
- victim = path("test-monitored/dir1/file2.txt")
- victim_id = self.system.store.get_resource_id (uri(victim))
- os.remove (victim)
- self.system.store.await_resource_deleted (victim_id)
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 2)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
-
- # Restore the file
- f = open (victim, "w")
- f.write ("Don't panic, everything is fine")
- f.close ()
- self.system.store.await_resource_inserted ('nfo:TextDocument', uri(victim))
-
- def test_09_deletion_directory (self):
- """
- Delete a directory
- """
- victim = path("test-monitored/dir1")
- victim_id = self.system.store.get_resource_id (uri(victim))
- shutil.rmtree (victim)
-
- file_inside_victim_url = uri (os.path.join (victim, "file2.txt"))
- file_inside_victim_id = self.system.store.get_resource_id (file_inside_victim_url)
- self.system.store.await_resource_deleted (file_inside_victim_id)
-
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 1)
- unpacked_result = [ r[0] for r in result]
- self.assertIn ( uri ("test-monitored/file1.txt"), unpacked_result)
-
- # Restore the dirs
- os.makedirs (path("test-monitored/dir1"))
- os.makedirs (path("test-monitored/dir1/dir2"))
- for f in ["test-monitored/dir1/file2.txt",
- "test-monitored/dir1/dir2/file3.txt"]:
- filename = path(f)
- writer = open (filename, "w")
- writer.write ("Don't panic, everything is fine")
- writer.close ()
- self.system.store.await_resource_inserted ('nfo:TextDocument', uri(f))
-
- # Check everything is fine
- result = self.__get_text_documents ()
- self.assertEquals (len (result), 3)
-
-if __name__ == "__main__":
- print """
- Tests for Copy/move/delete operations of FILES between monitored/unmonitored locations.
-
- We need to do the same for DIRECTORIES!
- """
- ut.main()
diff --git a/tests/functional-tests/301-miner-resource-removal.py b/tests/functional-tests/301-miner-resource-removal.py
deleted file mode 100755
index 9c2acbc20..000000000
--- a/tests/functional-tests/301-miner-resource-removal.py
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2010, Nokia (ivan.frade@nokia.com)
-#
-# 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.
-
-"""
-Test that resource removal does not leave debris or clobber too much,
-especially in the case where nie:InformationElement != nie:DataObject
-"""
-
-from common.utils import configuration as cfg
-from common.utils.minertest import CommonTrackerMinerTest, path, uri
-
-from gi.repository import GLib
-
-import os
-import unittest2 as ut
-
-MINER_TMP_DIR = cfg.TEST_MONITORED_TMP_DIR
-
-
-CONF_OPTIONS = {
- cfg.DCONF_MINER_SCHEMA: {
- 'enable-writeback': GLib.Variant.new_boolean(False),
- 'index-recursive-directories': GLib.Variant.new_strv([MINER_TMP_DIR]),
- 'index-single-directories': GLib.Variant.new_strv([]),
- 'index-optical-discs': GLib.Variant.new_boolean(False),
- 'index-removable-devices': GLib.Variant.new_boolean(False),
- 'throttle': GLib.Variant.new_int32(5),
- }
-}
-
-
-class MinerResourceRemovalTest (CommonTrackerMinerTest):
-
- def prepare_directories (self):
- # Override content from the base class
- pass
-
- def create_test_content (self, file_urn, title):
- sparql = "INSERT { \
- _:ie a nmm:MusicPiece ; \
- nie:title \"%s\" ; \
- nie:isStoredAs <%s> \
- } " % (title, file_urn)
-
- self.tracker.update (sparql)
-
- return self.tracker.await_resource_inserted (rdf_class = 'nmm:MusicPiece',
- title = title)
-
- def create_test_file (self, file_name):
- file_path = path(file_name)
-
- file = open (file_path, 'w')
- file.write ("Test")
- file.close ()
-
- return self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
- url = uri(file_name))
-
- def test_01_file_deletion (self):
- """
- Ensure every logical resource (nie:InformationElement) contained with
- in a file is deleted when the file is deleted.
- """
-
- (file_1_id, file_1_urn) = self.create_test_file ("test-monitored/test_1.txt")
- (file_2_id, file_2_urn) = self.create_test_file ("test-monitored/test_2.txt")
- (ie_1_id, ie_1_urn) = self.create_test_content (file_1_urn, "Test resource 1")
- (ie_2_id, ie_2_urn) = self.create_test_content (file_2_urn, "Test resource 2")
-
- os.unlink (path ("test-monitored/test_1.txt"))
-
- self.tracker.await_resource_deleted (file_1_id)
- self.tracker.await_resource_deleted (ie_1_id,
- "Associated logical resource failed to be deleted " \
- "when its containing file was removed.")
-
- self.assertResourceMissing (file_1_urn)
- self.assertResourceMissing (ie_1_urn)
- self.assertResourceExists (file_2_urn)
- self.assertResourceExists (ie_2_urn)
-
- #def test_02_removable_device_data (self):
- # """
- # Tracker does periodic cleanups of data on removable volumes that haven't
- # been seen since 'removable-days-threshold', and will also remove all data
- # from removable volumes if 'index-removable-devices' is disabled.
- #
- # FIXME: not yet possible to test this - we need some way of mounting
- # a fake removable volume: https://bugzilla.gnome.org/show_bug.cgi?id=659739
- # """
-
- #dconf = DConfClient ()
- #dconf.write (cfg.DCONF_MINER_SCHEMA, 'index-removable-devices', 'true')
-
- #self.mount_test_removable_volume ()
-
- #self.add_test_resource ("urn:test:1", test_volume_urn)
- #self.add_test_resource ("urn:test:2", None)
-
- # Trigger removal of all resources from removable devices
- #dconf.write (cfg.DCONF_MINER_SCHEMA, 'index-removable-devices', 'false')
-
- # Check that only the data on the removable volume was deleted
- #self.await_updates (2)
-
-
-if __name__ == "__main__":
- ut.main()
diff --git a/tests/functional-tests/310-fts-indexing.py b/tests/functional-tests/310-fts-indexing.py
deleted file mode 100755
index 4673da604..000000000
--- a/tests/functional-tests/310-fts-indexing.py
+++ /dev/null
@@ -1,334 +0,0 @@
-#!/usr/bin/python
-#-*- coding: utf-8 -*-
-
-# Copyright (C) 2010, Nokia (ivan.frade@nokia.com)
-#
-# 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.
-
-#
-# TODO:
-# These tests are for files... we need to write them for folders!
-#
-"""
-Monitor a directory, copy/move/remove/update text files and check that
-the text contents are updated accordingly in the indexes.
-"""
-import os
-import shutil
-import locale
-import time
-
-import unittest2 as ut
-from common.utils.helpers import log
-from common.utils.minertest import CommonTrackerMinerTest, MINER_TMP_DIR, uri, path, DEFAULT_TEXT
-from common.utils import configuration as cfg
-
-class CommonMinerFTS (CommonTrackerMinerTest):
- """
- Superclass to share methods. Shouldn't be run by itself.
- """
- def prepare_directories (self):
- # Override content from the base class
- pass
-
- def setUp (self):
- self.testfile = "test-monitored/miner-fts-test.txt"
- if os.path.exists (path (self.testfile)):
- os.remove (path (self.testfile))
-
- super(CommonMinerFTS, self).setUp()
-
- def set_text (self, text):
- exists = os.path.exists(path(self.testfile))
-
- f = open (path (self.testfile), "w")
- f.write (text)
- f.close ()
-
- if exists:
- subject_id = self.tracker.get_resource_id(uri(self.testfile))
- self.tracker.await_property_changed(
- subject_id=subject_id, property_uri='nie:plainTextContent')
- else:
- self.tracker.await_resource_inserted(
- rdf_class='nfo:Document', url=uri(self.testfile),
- required_property='nie:plainTextContent')
-
- self.tracker.reset_graph_updates_tracking()
-
- def search_word (self, word):
- """
- Return list of URIs with the word in them
- """
- log ("Search for: %s" % word)
- results = self.tracker.query ("""
- SELECT ?url WHERE {
- ?u a nfo:TextDocument ;
- nie:url ?url ;
- fts:match '%s'.
- }
- """ % (word))
- return [r[0] for r in results]
-
- def basic_test (self, text, word):
- """
- Save the text on the testfile, search the word
- and assert the testfile is only result.
-
- Be careful with the default contents of the text files
- ( see common/utils/minertest.py DEFAULT_TEXT )
- """
- self.set_text (text)
- results = self.search_word (word)
- self.assertEquals (len (results), 1)
- self.assertIn ( uri (self.testfile), results)
-
- def _query_id (self, uri):
- query = "SELECT tracker:id(?urn) WHERE { ?urn nie:url \"%s\". }" % uri
- result = self.tracker.query (query)
- assert len (result) == 1
- return int (result[0][0])
-
-
-class MinerFTSBasicTest (CommonMinerFTS):
- """
- Tests different contents in a single file
- """
-
- def test_01_single_word (self):
- TEXT = "automobile"
- self.basic_test (TEXT, TEXT)
-
- def test_02_multiple_words (self):
- TEXT = "automobile with unlimited power"
- self.set_text (TEXT)
-
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 1)
- self.assertIn (uri (self.testfile), results)
-
- results = self.search_word ("unlimited")
- self.assertEquals (len (results), 1)
- self.assertIn (uri (self.testfile), results)
-
-
- def test_03_long_word (self):
- # TEXT is longer than the 20 characters specified in the fts configuration
- TEXT = "fsfsfsdfskfweeqrewqkmnbbvkdasdjefjewriqjfnc"
- self.set_text (TEXT)
-
- results = self.search_word (TEXT)
- self.assertEquals (len (results), 0)
-
- def test_04_non_existent_word (self):
- TEXT = "This a trick"
- self.set_text (TEXT)
- results = self.search_word ("trikc")
- self.assertEquals (len (results), 0)
-
-
- def test_05_word_in_multiple_files (self):
- # Safeguard, in the case we modify the DEFAULT_TEXT later...
- assert "content" in DEFAULT_TEXT
-
- self.set_text (DEFAULT_TEXT)
- results = self.search_word ("content")
- self.assertEquals (len (results), 4)
- self.assertIn ( uri (self.testfile), results)
- self.assertIn ( uri ("test-monitored/file1.txt"), results)
- self.assertIn ( uri ("test-monitored/dir1/file2.txt"), results)
- self.assertIn ( uri ("test-monitored/dir1/dir2/file3.txt"), results)
-
- def test_06_word_multiple_times_in_file (self):
- TEXT = "automobile is red. automobile is big. automobile is great!"
- self.basic_test (TEXT, "automobile")
-
- def test_07_sentence (self):
- TEXT = "plastic is fantastic"
- self.basic_test (TEXT, TEXT)
-
- def test_08_partial_sentence (self):
- TEXT = "plastic is fantastic"
- self.basic_test (TEXT, "is fantastic")
-
- def test_09_strange_word (self):
- # FIXME Not sure what are we testing here
- TEXT = "'summer.time'"
- self.basic_test (TEXT, "summer.time")
-
- # Skip the test 'search for .'
-
- def test_10_mixed_letters_and_numbers (self):
- TEXT = "abc123"
- self.basic_test (TEXT, "abc123")
-
- def test_11_ignore_numbers (self):
- TEXT = "palabra 123123"
- self.set_text (TEXT)
- results = self.search_word ("123123")
- self.assertEquals (len (results), 0)
-
-
-class MinerFTSFileOperationsTest (CommonMinerFTS):
- """
- Move, update, delete the files and check the text indexes are updated accordingly.
- """
-
- def test_01_removal_of_file (self):
- """
- When removing the file, its text contents disappear from the index
- """
- TEXT = "automobile is red and big and whatnot"
- self.basic_test (TEXT, "automobile")
-
- id = self._query_id (uri (self.testfile))
- os.remove ( path (self.testfile))
- self.tracker.await_resource_deleted (id)
-
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 0)
-
- def test_02_empty_the_file (self):
- """
- Emptying the file, the indexed words are also removed
-
- FIXME: this test currently fails!
- """
- TEXT = "automobile is red and big and whatnot"
- self.basic_test (TEXT, "automobile")
-
- self.set_text ("")
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 0)
-
- def test_03_update_the_file (self):
- """
- Changing the contents of the file, updates the index
-
- FIXME: this test fails!
- """
- TEXT = "automobile is red and big and whatnot"
- self.basic_test (TEXT, "automobile")
-
- self.set_text ("airplane is blue and small and wonderful")
-
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 0)
-
- results = self.search_word ("airplane")
- self.assertEquals (len (results), 1)
-
- # Skip the test_text_13... feel, feet, fee in three diff files and search feet
-
- def __recreate_file (self, filename, content):
- if os.path.exists (filename):
- os.remove (filename)
-
- f = open (filename, "w")
- f.write (content)
- f.close ()
-
-
- def test_04_on_unmonitored_file (self):
- """
- Set text in an unmonitored file. There should be no results.
- """
- TEXT = "automobile is red"
-
- TEST_15_FILE = "test-no-monitored/fts-indexing-test-15.txt"
- self.__recreate_file (path (TEST_15_FILE), TEXT)
-
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 0)
-
- os.remove (path (TEST_15_FILE))
-
- def test_05_move_file_unmonitored_monitored (self):
- """
- Move file from unmonitored location to monitored location and index should be updated
- """
-
- TEXT = "airplane is beautiful"
- TEST_16_SOURCE = "test-no-monitored/fts-indexing-text-16.txt"
- TEST_16_DEST = "test-monitored/fts-indexing-text-16.txt"
-
- self.__recreate_file (path (TEST_16_SOURCE), TEXT)
- # the file is supposed to be ignored by tracker, so there is no notification..
- time.sleep (5)
-
- results = self.search_word ("airplane")
- self.assertEquals (len (results), 0)
-
- shutil.copyfile ( path (TEST_16_SOURCE), path (TEST_16_DEST))
- self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
- url = uri(TEST_16_DEST),
- required_property = 'nie:plainTextContent')
-
- results = self.search_word ("airplane")
- self.assertEquals (len (results), 1)
-
- os.remove ( path (TEST_16_SOURCE))
- os.remove ( path (TEST_16_DEST))
-
- # skip test for a file in a hidden directory
-
-class MinerFTSStopwordsTest (CommonMinerFTS):
- """
- Search for stopwords in a file
- """
-
- def __get_some_stopwords (self):
-
- langcode, encoding = locale.getdefaultlocale ()
- if "_" in langcode:
- langcode = langcode.split ("_")[0]
-
- stopwordsfile = os.path.join (cfg.DATADIR, "tracker", "stop-words", "stopwords." + langcode)
-
- if not os.path.exists (stopwordsfile):
- self.skipTest ("No stopwords for the current locale ('%s' doesn't exist)" % (stopwordsfile))
- return []
-
- stopwords = []
- counter = 0
- for line in open (stopwordsfile, "r"):
- if len (line) > 4:
- stopwords.append (line[:-1])
- counter += 1
-
- if counter > 5:
- break
-
- return stopwords
-
- def test_01_stopwords (self):
- stopwords = self.__get_some_stopwords ()
- TEXT = " ".join (["this a completely normal text automobile"] + stopwords)
-
- self.set_text (TEXT)
- results = self.search_word ("automobile")
- self.assertEquals (len (results), 1)
- log ("Stopwords: %s" % stopwords)
- for i in range (0, len (stopwords)):
- results = self.search_word (stopwords[i])
- self.assertEquals (len (results), 0)
-
- ## FIXME add all the special character tests!
- ## http://git.gnome.org/browse/tracker/commit/?id=81c0d3bd754a6b20ac72323481767dc5b4a6217b
-
-
-if __name__ == "__main__":
- ut.main ()
diff --git a/tests/functional-tests/400-extractor-metadata.py b/tests/functional-tests/400-extractor-metadata.py
deleted file mode 100755
index fc1604eb2..000000000
--- a/tests/functional-tests/400-extractor-metadata.py
+++ /dev/null
@@ -1,256 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2010, Nokia <ivan.frade@nokia.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-"""
-For a collection of files, call the extractor and check that the expected
-metadata is extracted. Load dynamically the test information from a data
-directory (containing xxx.expected files)
-"""
-
-from common.utils import configuration as cfg
-from common.utils.extractor import get_tracker_extract_output
-import unittest2 as ut
-import os
-import sys
-
-import ConfigParser
-
-
-class ExtractionTestCase (ut.TestCase):
- """
- Test checks if the tracker extractor is able to retrieve metadata
- """
- def __init__ (self, methodName='runTest', descfile=None):
- """
- Descfile is the description file in a relative path
- """
- ut.TestCase.__init__ (self, methodName)
-
- # Load the description file
- assert descfile
- self.rel_description = descfile
- self.configParser = self.__load_description_file (self.rel_description)
-
- # Add a method to the class called after the description file
- methodName = self.rel_description.lower()[:-len(".expected")].replace (" ", "_")[-60:]
-
- if (self.__is_expected_failure ()):
- setattr (self,
- methodName,
- self.expected_failure_test_extraction)
- else:
- setattr (self,
- methodName,
- self.generic_test_extraction)
-
- # unittest framework will run the test called "self._testMethodName"
- # So we set that variable to our new name
- self._testMethodName = methodName
-
- def runTest (self):
- """
- Empty function pointer, that should NEVER be called. It is required to exist by unittest.
- """
- assert False
-
- def __load_description_file (self, descfile):
- configParser = ConfigParser.RawConfigParser ()
- # Make it case sensitive:
- configParser.optionxform = str
-
- abs_description = os.path.abspath (descfile)
- loaded_files = configParser.read (abs_description)
- if not abs_description in loaded_files:
- raise Exception("Unable to load %s" % (abs_description))
-
- return configParser
-
- def __is_expected_failure (self):
- assert self.configParser
- return self.configParser.has_option ("TestFile", "ExpectedFailure")
-
- def __get_bugnumber (self):
- assert self.configParser
- if self.configParser.has_option ("TestFile", "Bugzilla"):
- return "'" + self.configParser.get ("TestFile", "Bugzilla") + "'"
- else:
- return None
-
- def expected_failure_test_extraction (self):
- try:
- self.generic_test_extraction ()
- except Exception:
- raise ut.case._ExpectedFailure(sys.exc_info())
-
- if self.__get_bugnumber ():
- raise Exception ("Unexpected success. Maybe bug: " + self.__get_bugnumber () + " has been fixed?")
- else:
- raise Exception ("Unexpected success. Check " + self.rel_description)
-
- def generic_test_extraction (self):
- abs_description = os.path.abspath (self.rel_description)
-
- # Filename contains the file to extract, in a relative path to the description file
- desc_root, desc_file = os.path.split (abs_description)
-
- filename_to_extract = self.configParser.get ("TestFile", "Filename")
- self.file_to_extract = os.path.join (desc_root, filename_to_extract)
-
- result = get_tracker_extract_output(self.file_to_extract)
- self.__assert_extraction_ok (result)
-
- def assertDictHasKey (self, d, key, msg=None):
- if not d.has_key (key):
- standardMsg = "Missing: %s\n" % (key)
- self.fail (self._formatMessage (msg, standardMsg))
- else:
- return
-
- def assertIsURN (self, supposed_uuid, msg=None):
- import uuid
-
- try:
- if (supposed_uuid.startswith ("<") and supposed_uuid.endswith (">")):
- supposed_uuid = supposed_uuid[1:-1]
-
- uuid.UUID (supposed_uuid)
- except ValueError:
- standardMsg = "'%s' is not a valid UUID" % (supposed_uuid)
- self.fail (self._formatMessage (msg, standardMsg))
-
- def __assert_extraction_ok (self, result):
- self.__check_section ("Metadata", result)
-
- def __check_section (self, section, result):
- error_missing_prop = "Property '%s' hasn't been extracted from file \n'%s'\n (requested on '%s' [%s])"
- error_wrong_value = "on property '%s' from file %s\n (requested on: '%s' [%s])"
- error_extra_prop = "Property '%s' was explicitely banned for file \n'%s'\n (requested on '%s' [%s])"
- error_extra_prop_v = "Property '%s' with value '%s' was explicitely banned for file \n'%s'\n (requested on %s' [%s])"
-
- expected_pairs = [] # List of expected (key, value)
- unexpected_pairs = [] # List of unexpected (key, value)
- expected_keys = [] # List of expected keys (the key must be there, value doesnt matter)
-
- for k, v in self.configParser.items (section):
- if k.startswith ("!"):
- unexpected_pairs.append ( (k[1:].replace ("_", ":"), v) )
- elif k.startswith ("@"):
- expected_keys.append ( k[1:].replace ("_", ":") )
- else:
- expected_pairs.append ( (k.replace ("_", ":"), v) )
-
-
- for (prop, value) in expected_pairs:
- self.assertDictHasKey (result, prop,
- error_missing_prop % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
- if value == "@URNUUID@":
- # Watch out! We take only the FIRST element. Incompatible with multiple-valued props.
- self.assertIsURN (result [prop][0],
- error_wrong_value % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
- else:
- self.assertIn (value, result [prop],
- error_wrong_value % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
-
- for (prop, value) in unexpected_pairs:
- # There is no prop, or it is but not with that value
- if (value == ""):
- self.assertFalse (result.has_key (prop), error_extra_prop % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
- else:
- if (value == "@URNUUID@"):
- self.assertIsURN (result [prop][0], error_extra_prop % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
- else:
- self.assertNotIn (value, result [prop], error_extra_prop_v % (prop,
- value,
- self.file_to_extract,
- self.rel_description,
- section))
-
- for prop in expected_keys:
- self.assertDictHasKey (result, prop,
- error_missing_prop % (prop,
- self.file_to_extract,
- self.rel_description,
- section))
-
-
-def run_all ():
- ##
- # Traverse the TEST_DATA_PATH directory looking for .description files
- # Add a new TestCase to the suite per .description file and run the suite.
- #
- # Is we do this inside a single TestCase an error in one test would stop the whole
- # testing.
- ##
- if (os.path.exists (os.getcwd() + "/test-extraction-data")):
- # Use local directory if available
- TEST_DATA_PATH = os.getcwd() + "/test-extraction-data"
- else:
- TEST_DATA_PATH = os.path.join (cfg.DATADIR, "tracker-tests",
- "test-extraction-data")
- print "Loading test descriptions from", TEST_DATA_PATH
- extractionTestSuite = ut.TestSuite ()
- for root, dirs, files in os.walk (TEST_DATA_PATH):
- descriptions = [os.path.join (root, f) for f in files if f.endswith ("expected")]
- for descfile in descriptions:
- tc = ExtractionTestCase(descfile=descfile)
- extractionTestSuite.addTest(tc)
- result = ut.TextTestRunner (verbosity=1).run (extractionTestSuite)
- sys.exit(not result.wasSuccessful())
-
-def run_one (filename):
- ##
- # Run just one .description file
- ##
- description = os.path.join (os.getcwd (), filename)
-
- extractionTestSuite = ut.TestSuite ()
- tc = ExtractionTestCase(descfile=description)
- extractionTestSuite.addTest(tc)
-
- result = ut.TextTestRunner (verbosity=2).run (extractionTestSuite)
- sys.exit(not result.wasSuccessful())
-
-
-if __name__ == "__main__":
- if (len (sys.argv) == 1):
- run_all ()
- else:
- if os.path.exists (sys.argv[1]) and sys.argv[1].endswith (".expected"):
- run_one (sys.argv[1])
- # FIXME: for the case when invoked by testrunner (see create-tests-xml.py)
- elif sys.argv[1] == "ExtractionTestCase":
- run_all ()
- else:
- print "Usage: %s [FILE.expected]" % (sys.argv[0])
-
diff --git a/tests/functional-tests/410-extractor-decorator.py b/tests/functional-tests/410-extractor-decorator.py
deleted file mode 100755
index 1b8defb38..000000000
--- a/tests/functional-tests/410-extractor-decorator.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2016, 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.
-
-"""
-Tests failure cases of tracker-extract.
-"""
-
-import unittest2 as ut
-
-from gi.repository import GLib
-
-import os
-import shutil
-import time
-
-import common.utils.configuration as cfg
-from common.utils.helpers import log
-from common.utils.minertest import MINER_TMP_DIR, path, uri
-from common.utils.system import TrackerSystemAbstraction
-
-
-CONF_OPTIONS = {
- cfg.DCONF_MINER_SCHEMA: {
- 'index-recursive-directories': GLib.Variant.new_strv([]),
- 'index-single-directories': GLib.Variant.new_strv([MINER_TMP_DIR]),
- 'index-optical-discs': GLib.Variant.new_boolean(False),
- 'index-removable-devices': GLib.Variant.new_boolean(False),
- }
-}
-
-
-CORRUPT_FILE = os.path.join(
- os.path.dirname(__file__), 'test-extraction-data', 'audio',
- 'audio-corrupt.mp3')
-
-VALID_FILE = os.path.join(
- os.path.dirname(__file__), 'test-extraction-data', 'audio',
- 'audio-test-1.mp3')
-VALID_FILE_CLASS = 'nmm:MusicPiece'
-VALID_FILE_TITLE = 'Simply Juvenile'
-
-TRACKER_EXTRACT_FAILURE_DATA_SOURCE = 'tracker:extractor-failure-data-source'
-
-
-class ExtractorDecoratorTest(ut.TestCase):
- def setUp(self):
- if not os.path.exists(MINER_TMP_DIR):
- os.makedirs(MINER_TMP_DIR)
- assert os.path.isdir(MINER_TMP_DIR)
-
- self.system = TrackerSystemAbstraction(CONF_OPTIONS)
- self.system.tracker_miner_fs_testing_start()
-
- def tearDown(self):
- self.system.tracker_miner_fs_testing_stop()
-
- shutil.rmtree(MINER_TMP_DIR)
-
- def test_reextraction(self):
- """Tests whether known files are still re-extracted on user request."""
- miner_fs = self.system.miner_fs
- store = self.system.store
-
- # Insert a valid file and wait extraction of its metadata.
- file_path = os.path.join(MINER_TMP_DIR, os.path.basename(VALID_FILE))
- shutil.copy(VALID_FILE, file_path)
- file_id, file_urn = store.await_resource_inserted(
- VALID_FILE_CLASS, title=VALID_FILE_TITLE)
-
- # Remove a key piece of metadata.
- store.update(
- 'DELETE { <%s> nie:title ?title }'
- ' WHERE { <%s> nie:title ?title }' % (file_urn, file_urn))
- store.await_property_changed(file_id, 'nie:title')
- assert not store.ask('ASK { <%s> nie:title ?title }' % file_urn)
-
- log("Sending re-index request")
- # Request re-indexing (same as `tracker index --file ...`)
- miner_fs.index_file(uri(file_path))
-
- # The extractor should reindex the file and re-add the metadata that we
- # deleted, so we should see the nie:title property change.
- store.await_property_changed(file_id, 'nie:title')
-
- title_result = store.query('SELECT ?title { <%s> nie:title ?title }' % file_urn)
- assert len(title_result) == 1
- self.assertEqual(title_result[0][0], VALID_FILE_TITLE)
-
-
-if __name__ == '__main__':
- ut.main()
diff --git a/tests/functional-tests/500-writeback.py b/tests/functional-tests/500-writeback.py
deleted file mode 100755
index 3d6b018e2..000000000
--- a/tests/functional-tests/500-writeback.py
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2010, Nokia (ivan.frade@nokia.com)
-#
-# 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.
-#
-"""
-Write values in tracker and check the actual values are written
-on the files. Note that these tests are highly platform dependant.
-"""
-import os
-import time
-
-from common.utils.extractor import get_tracker_extract_output
-from common.utils.writebacktest import CommonTrackerWritebackTest as CommonTrackerWritebackTest
-import unittest2 as ut
-from common.utils.expectedFailure import expectedFailureBug
-
-REASONABLE_TIMEOUT = 5 # Seconds we wait for tracker-writeback to do the work
-
-class WritebackBasicDataTest (CommonTrackerWritebackTest):
- """
- Write in tracker store the properties witih writeback support and check
- that the new values are actually in the file
- """
- def setUp (self):
- self.tracker = self.system.store
- self.extractor = self.system.extractor
-
- def __clean_property (self, property_name, fileuri, expectFailure=True):
- """
- Remove the property for the fileuri (file://...)
- """
- CLEAN = """
- DELETE { ?u %s ?whatever }
- WHERE {
- ?u nie:url '%s' ;
- %s ?whatever .
-
- }
- """
- try:
- self.tracker.update (CLEAN % (property_name, fileuri, property_name))
- except Exception, e:
- print e
- assert expectFailure
-
-
- def __writeback_test (self, filename, mimetype, prop, expectedKey=None):
- """
- Set a value in @prop for the @filename. Then ask tracker-extractor
- for metadata and check in the results dictionary if the property is there.
-
- Note: given the special translation of some property-names in the dictionary
- with extracted metadata, there is an optional parameter @expectedKey
- to specify what property to check in the dictionary. If None, then
- the @prop is used.
- """
-
- # FIXME: filename is actually a URI! :(
- filename_real = filename[len('file://'):]
- initial_mtime = os.stat(filename_real).st_mtime
-
- TEST_VALUE = prop.replace (":","") + "test"
- SPARQL_TMPL = """
- INSERT { ?u %s '%s' }
- WHERE { ?u nie:url '%s' }
- """
- self.__clean_property (prop, filename)
- self.tracker.update (SPARQL_TMPL % (prop, TEST_VALUE, filename))
-
- self.wait_for_file_change(filename_real, initial_mtime)
-
- results = get_tracker_extract_output (filename, mimetype)
- keyDict = expectedKey or prop
- self.assertIn (TEST_VALUE, results[keyDict])
- self.__clean_property (prop, filename, False)
-
-
- def __writeback_hasTag_test (self, filename, mimetype):
-
- SPARQL_TMPL = """
- INSERT {
- <test://writeback-hasTag-test/1> a nao:Tag ;
- nao:prefLabel "testTag" .
-
- ?u nao:hasTag <test://writeback-hasTag-test/1> .
- } WHERE {
- ?u nie:url '%s' .
- }
- """
-
- CLEAN_VALUE = """
- DELETE {
- <test://writeback-hasTag-test/1> a rdfs:Resource.
- ?u nao:hasTag <test://writeback-hasTag-test/1> .
- } WHERE {
- ?u nao:hasTag <test://writeback-hasTag-test/1> .
- }
- """
-
- self.tracker.update (SPARQL_TMPL % (filename))
-
- time.sleep (REASONABLE_TIMEOUT)
-
- results = get_tracker_extract_output (filename, mimetype)
- self.assertIn ("testTag", results ["nao:hasTag"])
-
-
- # JPEG test
- def test_001_jpeg_title (self):
- #FILENAME = "test-writeback-monitored/writeback-test-1.jpeg"
- self.__writeback_test (self.get_test_filename_jpeg (), "image/jpeg", "nie:title")
-
- def test_002_jpeg_description (self):
- #FILENAME = "test-writeback-monitored/writeback-test-1.jpeg"
- self.__writeback_test (self.get_test_filename_jpeg (), "image/jpeg", "nie:description")
-
- def test_003_jpeg_keyword (self):
- #FILENAME = "test-writeback-monitored/writeback-test-1.jpeg"
- self.__writeback_test (self.get_test_filename_jpeg (), "image/jpeg",
- "nie:keyword", "nao:hasTag")
-
- def test_004_jpeg_hasTag (self):
- #FILENAME = "test-writeback-monitored/writeback-test-1.jpeg"
- self.__writeback_hasTag_test (self.get_test_filename_jpeg (), "image/jpeg")
-
-
- # TIFF tests
- def test_011_tiff_title (self):
- #FILANAME = "test-writeback-monitored/writeback-test-2.tif"
- self.__writeback_test (self.get_test_filename_tiff (), "image/tiff", "nie:title")
-
- def test_012_tiff_description (self):
- FILENAME = "test-writeback-monitored/writeback-test-2.tif"
- self.__writeback_test (self.get_test_filename_tiff (), "image/tiff", "nie:description")
-
- def test_013_tiff_keyword (self):
- FILENAME = "test-writeback-monitored/writeback-test-2.tif"
- self.__writeback_test (self.get_test_filename_tiff (), "image/tiff",
- "nie:keyword", "nao:hasTag")
-
- def test_014_tiff_hasTag (self):
- FILENAME = "test-writeback-monitored/writeback-test-2.tif"
- self.__writeback_hasTag_test (self.get_test_filename_tiff (), "image/tiff")
-
-
-
- # PNG tests
- @expectedFailureBug ("NB#185070")
- def test_021_png_title (self):
- FILENAME = "test-writeback-monitored/writeback-test-4.png"
- self.__writeback_test (self.get_test_filaname_png (), "image/png", "nie:title")
-
- @expectedFailureBug ("NB#185070")
- def test_022_png_description (self):
- FILENAME = "test-writeback-monitored/writeback-test-4.png"
- self.__writeback_test (self.get_test_filaname_png (), "image/png", "nie:description")
-
- @expectedFailureBug ("NB#185070")
- def test_023_png_keyword (self):
- FILENAME = "test-writeback-monitored/writeback-test-4.png"
- self.__writeback_test (self.get_test_filaname_png (), "image/png", "nie:keyword", "nao:hasTag:prefLabel")
-
- @expectedFailureBug("NB#185070")
- def test_024_png_hasTag (self):
- FILENAME = "test-writeback-monitored/writeback-test-4.png"
- self.__writeback_hasTag_test (self.get_test_filaname_png (), "image/png")
-
-if __name__ == "__main__":
- ut.main ()
diff --git a/tests/functional-tests/501-writeback-details.py b/tests/functional-tests/501-writeback-details.py
deleted file mode 100755
index c7adceb2f..000000000
--- a/tests/functional-tests/501-writeback-details.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (C) 2011, Nokia (ivan.frade@nokia.com)
-#
-# 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.
-#
-from common.utils.writebacktest import CommonTrackerWritebackTest as CommonTrackerWritebackTest
-from common.utils.extractor import get_tracker_extract_output
-from common.utils.helpers import log
-import unittest2 as ut
-from common.utils.expectedFailure import expectedFailureBug
-import os
-import time
-
-REASONABLE_TIMEOUT = 5 # Seconds we wait for tracker-writeback to do the work
-
-
-class WritebackKeepDateTest (CommonTrackerWritebackTest):
-
- def setUp (self):
- self.tracker = self.system.store
- self.extractor = self.system.extractor
- self.favorite = self.__prepare_favorite_tag ()
-
- def __prepare_favorite_tag (self):
- # Check here if favorite has tag... to make sure writeback is actually writing
- results = self.tracker.query ("""
- SELECT ?label WHERE { nao:predefined-tag-favorite nao:prefLabel ?label }""")
-
- if len (results) == 0:
- self.tracker.update ("""
- INSERT { nao:predefined-tag-favorite nao:prefLabel 'favorite'}
- WHERE { nao:predefined-tag-favorite a nao:Tag }
- """)
- return "favorite"
- else:
- return str(results[0][0])
-
-
- def test_01_NB217627_content_created_date (self):
- """
- NB#217627 - Order if results is different when an image is marked as favorite.
- """
- query_images = """
- SELECT nie:url(?u) ?contentCreated WHERE {
- ?u a nfo:Visual ;
- nfo:fileLastModified ?contentCreated
- } ORDER BY ?contentCreated
- """
- results = self.tracker.query (query_images)
- self.assertEquals (len (results), 3, results)
-
- log ("Waiting 2 seconds to ensure there is a noticiable difference in the timestamp")
- time.sleep (2)
-
- url = self.get_test_filename_jpeg ()
-
- filename = url[len('file://'):]
- initial_mtime = os.stat(filename).st_mtime
-
- # This triggers the writeback
- mark_as_favorite = """
- INSERT {
- ?u nao:hasTag nao:predefined-tag-favorite .
- } WHERE {
- ?u nie:url <%s> .
- }
- """ % url
- self.tracker.update (mark_as_favorite)
- log ("Setting favorite in <%s>" % url)
-
- self.wait_for_file_change (filename, initial_mtime)
-
- # Check the value is written in the file
- metadata = get_tracker_extract_output (filename, "")
- self.assertIn (self.favorite, metadata ["nao:hasTag"],
- "Tag hasn't been written in the file")
-
- # Now check the modification date of the files and it should be the same :)
- new_results = self.tracker.query (query_images)
- ## for (uri, date) in new_results:
- ## print "Checking dates of <%s>" % uri
- ## previous_date = convenience_dict[uri]
- ## print "Before: %s \nAfter : %s" % (previous_date, date)
- ## self.assertEquals (date, previous_date, "File <%s> has change its contentCreated date!" % uri)
-
- # Indeed the order of the results should be the same
- for i in range (0, len (results)):
- self.assertEquals (results[i][0], new_results[i][0], "Order of the files is different")
- self.assertEquals (results[i][1], new_results[i][1], "Date has change in file <%s>" % results[i][0])
-
-
-if __name__ == "__main__":
- ut.main ()
diff --git a/tests/functional-tests/600-applications-camera.py b/tests/functional-tests/600-applications-camera.py
deleted file mode 100755
index 31a7a56fa..000000000
--- a/tests/functional-tests/600-applications-camera.py
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2011, Nokia Corporation <ivan.frade@nokia.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-"""
-Tests trying to simulate the behaviour of applications working with tracker
-"""
-
-import os
-import random
-
-import unittest2 as ut
-from common.utils.applicationstest import CommonTrackerApplicationTest as CommonTrackerApplicationTest
-from common.utils.helpers import log
-
-
-class TrackerCameraTestSuite (CommonTrackerApplicationTest):
- """
- Common functionality for camera tests.
- """
-
- def insert_photo_resource_info (self, urn, file_url):
- """
- Insert new photo resource in the store, including nie:mimeType and nie:url
- """
- insert = """
- INSERT { <%(urn)s>
- a nie:InformationElement,
- nie:DataObject,
- nfo:Image,
- nfo:Media,
- nfo:Visual,
- nmm:Photo
- }
-
- DELETE { <%(urn)s> nie:mimeType ?_1 }
- WHERE { <%(urn)s> nie:mimeType ?_1 }
-
- INSERT { <%(urn)s>
- a rdfs:Resource ;
- nie:mimeType \"image/jpeg\"
- }
-
- DELETE { <%(urn)s> nie:url ?_2 }
- WHERE { <%(urn)s> nie:url ?_2 }
-
- INSERT { <%(urn)s>
- a rdfs:Resource ;
- nie:url \"%(file_url)s\" ;
- nie:isStoredAs <%(urn)s>
- }
- """ % locals()
- self.tracker.update (insert)
- self.assertEquals (self.get_urn_count_by_url (file_url), 1)
-
- def insert_video_resource_info (self, urn, file_url):
- """
- Insert new video resource in the store, including nie:mimeType and nie:url
- """
- insert = """
- INSERT { <%(urn)s>
- a nie:InformationElement,
- nie:DataObject,
- nfo:Video,
- nfo:Media,
- nfo:Visual,
- nmm:Video
- }
-
- DELETE { <%(urn)s> nie:mimeType ?_1 }
- WHERE { <%(urn)s> nie:mimeType ?_1 }
-
- INSERT { <%(urn)s>
- a rdfs:Resource ;
- nie:mimeType \"video/mp4\"
- }
-
- DELETE { <%(urn)s> nie:url ?_2 }
- WHERE { <%(urn)s> nie:url ?_2 }
-
- INSERT { <%(urn)s>
- a rdfs:Resource ;
- nie:url \"%(file_url)s\" ;
- nie:isStoredAs <%(urn)s>
- }
- """ % locals()
- self.tracker.update (insert)
- self.assertEquals (self.get_urn_count_by_url (file_url), 1)
-
- def insert_dummy_location_info (self, fileurn, geolocationurn, postaladdressurn):
- """
- Insert placeholder location info for a file
- """
- location_insert = """
- INSERT { <%s> a nco:PostalAddress ;
- nco:country \"SPAIN\" ;
- nco:locality \"Tres Cantos\"
- }
-
- INSERT { <%s> a slo:GeoLocation ;
- slo:postalAddress <%s>
- }
-
- INSERT { <%s> a rdfs:Resource ;
- slo:location <%s>
- }
- """ % (postaladdressurn, geolocationurn, postaladdressurn, fileurn, geolocationurn)
- self.tracker.update (location_insert)
-
-
-class TrackerCameraPicturesApplicationTests (TrackerCameraTestSuite):
-
- def test_01_camera_picture (self):
- """
- Camera simulation:
-
- 1. Create resource in the store for the new file
- 2. Write the file
- 3. Wait for miner-fs to index it
- 4. Ensure no duplicates are found
- """
-
- fileurn = "tracker://test_camera_picture_01/" + str(random.randint (0,100))
- origin_filepath = os.path.join (self.get_data_dir (), self.get_test_image ())
- dest_filepath = os.path.join (self.get_dest_dir (), self.get_test_image ())
- dest_fileuri = "file://" + dest_filepath
-
- self.insert_photo_resource_info (fileurn, dest_fileuri)
-
- # Copy the image to the dest path
- self.slowcopy_file (origin_filepath, dest_filepath)
- assert os.path.exists (dest_filepath)
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nmm:Photo', dest_fileuri)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest_filepath)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
-
- def test_02_camera_picture_geolocation (self):
- """
- Camera simulation:
-
- 1. Create resource in the store for the new file
- 2. Set nlo:location
- 2. Write the file
- 3. Wait for miner-fs to index it
- 4. Ensure no duplicates are found
- """
-
- fileurn = "tracker://test_camera_picture_02/" + str(random.randint (0,100))
- dest_filepath = os.path.join (self.get_dest_dir (), self.get_test_image ())
- dest_fileuri = "file://" + dest_filepath
-
- geolocationurn = "tracker://test_camera_picture_02_geolocation/" + str(random.randint (0,100))
- postaladdressurn = "tracker://test_camera_picture_02_postaladdress/" + str(random.randint (0,100))
-
- self.insert_photo_resource_info (fileurn, dest_fileuri)
-
- # FIRST, open the file for writing, and just write some garbage, to simulate that
- # we already started recording the video...
- fdest = open (dest_filepath, 'wb')
- fdest.write ("some garbage written here")
- fdest.write ("to simulate we're recording something...")
- fdest.seek (0)
-
- # SECOND, set slo:location
- self.insert_dummy_location_info (fileurn, geolocationurn, postaladdressurn)
-
- #THIRD, start copying the image to the dest path
- original_file = os.path.join (self.get_data_dir (),self.get_test_image ())
- self.slowcopy_file_fd (original_file, fdest)
- fdest.close ()
- assert os.path.exists (dest_filepath)
-
- # FOURTH, ensure we have only 1 resource
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nmm:Photo', dest_fileuri)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest_filepath)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
-
-
-class TrackerCameraVideosApplicationTests (TrackerCameraTestSuite):
-
- def test_01_camera_video (self):
- """
- Camera video recording simulation:
-
- 1. Create resource in the store for the new file
- 2. Write the file
- 3. Wait for miner-fs to index it
- 4. Ensure no duplicates are found
- """
-
- fileurn = "tracker://test_camera_video_01/" + str(random.randint (0,100))
- origin_filepath = os.path.join (self.get_data_dir (), self.get_test_video ())
- dest_filepath = os.path.join (self.get_dest_dir (), self.get_test_video ())
- dest_fileuri = "file://" + dest_filepath
-
- self.insert_video_resource_info(fileurn, dest_fileuri)
-
- # Copy the image to the dest path
- self.slowcopy_file (origin_filepath, dest_filepath)
- assert os.path.exists (dest_filepath)
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nmm:Video', dest_fileuri)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest_filepath)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
-
-
- def test_02_camera_video_geolocation (self):
- """
- Camera simulation:
-
- 1. Create resource in the store for the new file
- 2. Set nlo:location
- 2. Write the file
- 3. Wait for miner-fs to index it
- 4. Ensure no duplicates are found
- """
-
- fileurn = "tracker://test_camera_video_02/" + str(random.randint (0,100))
- origin_filepath = os.path.join (self.get_data_dir (), self.get_test_video ())
- dest_filepath = os.path.join (self.get_dest_dir (), self.get_test_video ())
- dest_fileuri = "file://" + dest_filepath
-
- geolocationurn = "tracker://test_camera_video_02_geolocation/" + str(random.randint (0,100))
- postaladdressurn = "tracker://test_camera_video_02_postaladdress/" + str(random.randint (0,100))
-
- self.insert_video_resource_info (fileurn, dest_fileuri)
-
- # FIRST, open the file for writing, and just write some garbage, to simulate that
- # we already started recording the video...
- fdest = open (dest_filepath, 'wb')
- fdest.write ("some garbage written here")
- fdest.write ("to simulate we're recording something...")
- fdest.seek (0)
-
- # SECOND, set slo:location
- self.insert_dummy_location_info (fileurn, geolocationurn, postaladdressurn)
-
- #THIRD, start copying the image to the dest path
- self.slowcopy_file_fd (origin_filepath, fdest)
- fdest.close ()
- assert os.path.exists (dest_filepath)
-
- # FOURTH, ensure we have only 1 resource
- dest_id, dest_urn = self.system.store.await_resource_inserted ('nmm:Video', dest_fileuri)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest_filepath)
- self.system.store.await_resource_deleted (dest_id)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
-
-if __name__ == "__main__":
- ut.main()
-
-
diff --git a/tests/functional-tests/601-applications-sync.py b/tests/functional-tests/601-applications-sync.py
deleted file mode 100755
index 2b32a723e..000000000
--- a/tests/functional-tests/601-applications-sync.py
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2011, Nokia Corporation <ivan.frade@nokia.com>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-"""
-Tests trying to simulate the behaviour of applications working with tracker
-"""
-
-import sys,os,dbus
-import unittest
-import time
-import random
-import string
-import datetime
-import shutil
-import fcntl
-
-from common.utils import configuration as cfg
-import unittest2 as ut
-from common.utils.applicationstest import CommonTrackerApplicationTest as CommonTrackerApplicationTest
-from common.utils.helpers import log
-
-
-class TrackerSyncApplicationTests (CommonTrackerApplicationTest):
-
- def test_01_sync_audio_nb219946 (self):
- """
- Sync simulation (after fix for NB#219946):
-
- 1. Create resource in the store for the new file, using blank nodes
- 2. Write the file
- 3. Wait for miner-fs to index it
- 4. Ensure no duplicates are found
-
- During stage 3 you should see the following error from the FS miner, if
- viewing its logs:
-
- (tracker-miner-fs:16008): Tracker-CRITICAL **: (Sparql buffer)
- Error in task 0 of the array-update: UNIQUE constraint failed:
- nie:DataObject.nie:url (strerror of errno ...)
-
- (tracker-miner-fs:16008): Tracker-CRITICAL **: Could not execute
- sparql: UNIQUE constraint failed: nie:DataObject.nie:url
- (strerror of errno ...)
-
- This is because the test already inserted the resource in the store.
- """
-
- origin_filepath = os.path.join (self.get_data_dir (), self.get_test_music ())
- dest_filepath = os.path.join (self.get_dest_dir (), self.get_test_music ())
- dest_fileuri = "file://" + dest_filepath
-
- log ("Synchronizing audio file in '%s'..." % (dest_filepath))
-
- # Insert new resource in the store
- insert = """
- DELETE { ?file a rdfs:Resource }
- WHERE { ?file nie:url '%s'}
-
- INSERT { _:x a nie:DataObject,
- nmm:MusicPiece,
- nfo:Media,
- nfo:Audio,
- nie:InformationElement ;
- nie:url '%s' ;
- nmm:musicAlbum <urn:album:SinCos> ;
- nfo:duration '15' ;
- nmm:performer <urn:artist:AbBaby> ;
- nmm:trackNumber '13' ;
- nfo:averageAudioBitrate '32000' ;
- nfo:genre 'Pop' ;
- nfo:isContentEncrypted 'false' ;
- nie:title 'Simply Juvenile' ;
- nie:isStoredAs _:x
- }
-
- INSERT { <urn:album:SinCos> a nmm:MusicAlbum;
- nie:title 'SinCos'
- }
-
- INSERT { <urn:artist:AbBaby> a nmm:Artist;
- nmm:artistName 'AbBaby'
- }
- """ % (dest_fileuri, dest_fileuri)
- self.tracker.update (insert)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- resource_id = self.tracker.get_resource_id(dest_fileuri)
-
- # Copy the image to the dest path
- self.slowcopy_file (origin_filepath, dest_filepath)
- assert os.path.exists (dest_filepath)
- self.tracker.await_resource_inserted ('nmm:MusicPiece', url=dest_fileuri)
-
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
-
- # Clean the new file so the test directory is as before
- log ("Remove and wait")
- os.remove (dest_filepath)
- self.tracker.await_resource_deleted (resource_id)
- self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
-
-if __name__ == "__main__":
- ut.main()
-
-
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 8b1e72077..db6225558 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -1,7 +1,6 @@
SUBDIRS = \
ipc \
common \
- test-apps-data \
ttl \
unittest2 \
test-ontologies
@@ -33,19 +32,7 @@ standard_tests += \
15-statistics.py \
16-collation.py \
17-ontology-changes.py \
- 200-backup-restore.py \
- 300-miner-basic-ops.py \
- 301-miner-resource-removal.py
-if HAVE_TRACKER_FTS
-standard_tests += 310-fts-indexing.py
-endif
-standard_tests += \
- 400-extractor-metadata.py \
- 410-extractor-decorator.py \
- 500-writeback.py \
- 501-writeback-details.py \
- 600-applications-camera.py \
- 601-applications-sync.py
+ 200-backup-restore.py
slow_tests = \
10-sqlite-misused.py \
diff --git a/tests/functional-tests/meson.build b/tests/functional-tests/meson.build
index af8085389..8261e1427 100644
--- a/tests/functional-tests/meson.build
+++ b/tests/functional-tests/meson.build
@@ -21,15 +21,6 @@ functional_tests = [
'16-collation',
'17-ontology-changes',
'200-backup-restore',
- '300-miner-basic-ops',
- '301-miner-resource-removal',
- '310-fts-indexing',
- '400-extractor-metadata',
- '410-extractor-decorator',
- '500-writeback',
- '501-writeback-details',
- '600-applications-camera',
- '601-applications-sync',
]
foreach t: functional_tests
diff --git a/tests/functional-tests/test-apps-data/Makefile.am b/tests/functional-tests/test-apps-data/Makefile.am
deleted file mode 100644
index ccdd73079..000000000
--- a/tests/functional-tests/test-apps-data/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-appstestdir = $(datadir)/tracker-tests/test-apps-data
-
-appstest_DATA = \
- test-image-1.jpg \
- test-music-1.mp3 \
- test-video-1.mp4
-
-EXTRA_DIST = $(appstest_DATA)
diff --git a/tests/functional-tests/test-apps-data/test-image-1.jpg b/tests/functional-tests/test-apps-data/test-image-1.jpg
deleted file mode 100644
index f1f917bb5..000000000
--- a/tests/functional-tests/test-apps-data/test-image-1.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/functional-tests/test-apps-data/test-music-1.mp3 b/tests/functional-tests/test-apps-data/test-music-1.mp3
deleted file mode 100644
index bbd4c768d..000000000
--- a/tests/functional-tests/test-apps-data/test-music-1.mp3
+++ /dev/null
Binary files differ
diff --git a/tests/functional-tests/test-apps-data/test-video-1.mp4 b/tests/functional-tests/test-apps-data/test-video-1.mp4
deleted file mode 100644
index 915e4be13..000000000
--- a/tests/functional-tests/test-apps-data/test-video-1.mp4
+++ /dev/null
Binary files differ