Commit cddec580 authored by Sam Thursfield's avatar Sam Thursfield

Merge branch 'sam/test-runner-fix'

This fixes many issues in the functional test suite.

Some issues remain, so the overall merge request here is still open:
!27
parents a48645d4 125d7074
Pipeline #58126 passed with stage
in 58 seconds
schemas = [
'org.freedesktop.Tracker.Extract.gschema.xml',
'org.freedesktop.Tracker.Miner.Files.gschema.xml',
'org.freedesktop.Tracker.Writeback.gschema.xml',
]
foreach schema : schemas
schemas = configure_file(
input: schema,
output: schema,
copy: true,
install: true,
install_dir: gsettings_schema_dir)
endforeach
tracker_miners_settings_enums = custom_target('tracker-miners-common-settings-enums',
input: '../src/libtracker-miners-common/tracker-enums.h',
output: 'org.freedesktop.TrackerMiners.enums.xml',
command: [glib_mkenums,
'--comments', '<!-- @comment@ -->',
'--fhead', '<schemalist>',
'--vhead', '<@type@ id="org.freedesktop.TrackerMiners.@EnumName@">',
'--vprod', ' <value nick="@valuenick@" value="@valuenum@"/>',
'--vtail', ' </@type@>',
'--ftail', '</schemalist>', '@INPUT@'],
capture: true,
install: true,
install_dir: gsettings_schema_dir)
# for unit tests
custom_target('tracker-miners-compile-schemas',
output: 'gschemas.compiled',
command: [find_program('glib-compile-schemas'), meson.current_build_dir()],
build_by_default: true,
depends: tracker_miners_settings_enums)
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<schemalist>
<schema id="org.freedesktop.Tracker.Extract" path="/org/freedesktop/tracker/extract/" gettext-domain="tracker-miners">
<key name="verbosity" enum="org.freedesktop.TrackerMiners.TrackerVerbosity">
<default>'errors'</default>
<summary>Log verbosity</summary>
<description>Log verbosity.</description>
</key>
<key name="sched-idle" enum="org.freedesktop.TrackerMiners.TrackerSchedIdle">
<default>'first-index'</default>
<summary>Scheduler priority when idle</summary>
<description>
The scheduler is the kernel component that decides which
runnable application will be executed by the CPU next. Each
application has an associated scheduling policy and priority.
</description>
</key>
<key name="max-bytes" type="i">
<summary>Max bytes to extract</summary>
<description>Maximum number of UTF-8 bytes to extract.</description>
<range min="0" max="10485760"/>
<default>1048576</default>
</key>
<key name="max-media-art-width" type="i">
<summary>Max media art width</summary>
<description>Maximum width in pixels for any media art extracted. Anything bigger is resized. Set to -1 to disable saving media art from files. Setting to 0 sets no limit on the media art width.</description>
<range min="-1" max="2048"/>
<default>0</default>
</key>
<key name="wait-for-miner-fs" type="b">
<summary>Wait for FS miner to be done before extracting</summary>
<description>When true, tracker-extract will wait for tracker-miner-fs to be done crawling before extracting meta-data. This option is useful on constrained environment where it is important to list files as fast as possible and can wait to get meta-data later.</description>
<default>false</default>
</key>
</schema>
</schemalist>
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<schemalist>
<schema id="org.freedesktop.Tracker.Miner.Files" path="/org/freedesktop/tracker/miner/files/" gettext-domain="tracker-miners">
<key name="verbosity" enum="org.freedesktop.TrackerMiners.TrackerVerbosity">
<default>'errors'</default>
<summary>Log verbosity</summary>
<description>Log verbosity.</description>
</key>
<key name="initial-sleep" type="i">
<summary>Initial sleep</summary>
<description>Initial sleep time, in seconds.</description>
<range min="0" max="1000"/>
<default>15</default>
</key>
<key name="sched-idle" enum="org.freedesktop.TrackerMiners.TrackerSchedIdle">
<default>'first-index'</default>
<summary>Scheduler priority when idle</summary>
<description>
The scheduler is the kernel component that decides which
runnable application will be executed by the CPU next. Each
application has an associated scheduling policy and priority.
</description>
</key>
<key name="throttle" type="i">
<summary>Throttle</summary>
<description>Indexing speed, the higher the slower.</description>
<range min="0" max="20"/>
<default>0</default>
</key>
<key name="low-disk-space-limit" type="i">
<summary>Low disk space limit</summary>
<description>Disk space threshold in percent at which to pause indexing, or -1 to disable.</description>
<range min="-1" max="100"/>
<default>-1</default>
</key>
<key name="crawling-interval" type="i">
<summary>Crawling interval</summary>
<description>
Interval in days to check whether the filesystem is up to date in the database.
0 forces crawling anytime, -1 forces it only after unclean shutdowns, and -2
disables it entirely.
</description>
<range min="-2" max="365"/>
<default>-1</default>
</key>
<key name="removable-days-threshold" type="i">
<summary>Removable devices’ data permanence threshold</summary>
<description>
Threshold in days after which files from removables devices
will be removed from database if not mounted. 0 means never,
maximum is 365.
</description>
<range min="0" max="365"/>
<default>3</default>
</key>
<key name="enable-monitors" type="b">
<summary>Enable monitors</summary>
<description>Set to false to completely disable any file monitoring</description>
<default>true</default>
</key>
<key name="enable-writeback" type="b">
<summary>Enable writeback</summary>
<description>Set to false to completely disable any file writeback</description>
<default>true</default>
</key>
<key name="index-removable-devices" type="b">
<summary>Index removable devices</summary>
<description>Set to true to enable indexing mounted directories for removable devices.</description>
<default>false</default>
</key>
<key name="index-optical-discs" type="b">
<summary>Index optical discs</summary>
<description>
Set to true to enable indexing CDs, DVDs, and generally optical media
(if removable devices are not indexed, optical discs won’t be either)
</description>
<default>false</default>
</key>
<key name="index-on-battery" type="b">
<summary>Index when running on battery</summary>
<description>Set to true to index while running on battery</description>
<default>true</default>
</key>
<key name="index-on-battery-first-time" type="b">
<summary>Perform initial indexing when running on battery</summary>
<description>Set to true to index while running on battery for the first time only</description>
<default>true</default>
</key>
<key name="index-recursive-directories" type="as">
<summary>Directories to index recursively</summary>
<description>
List of directories to index recursively, Special values include:
&amp;DESKTOP, &amp;DOCUMENTS, &amp;DOWNLOAD, &amp;MUSIC, &amp;PICTURES,
&amp;PUBLIC_SHARE, &amp;TEMPLATES, &amp;VIDEOS.
See /etc/xdg/user-dirs.defaults and $HOME/.config/user-dirs.default
</description>
<default>[ '&amp;DESKTOP', '&amp;DOCUMENTS', '&amp;DOWNLOAD', '&amp;MUSIC', '&amp;PICTURES', '&amp;VIDEOS' ]</default>
</key>
<key name="index-single-directories" type="as">
<summary>Directories to index non-recursively</summary>
<description>
List of directories to index without inspecting subfolders, Special values include:
&amp;DESKTOP, &amp;DOCUMENTS, &amp;DOWNLOAD, &amp;MUSIC, &amp;PICTURES,
&amp;PUBLIC_SHARE, &amp;TEMPLATES, &amp;VIDEOS.
See /etc/xdg/user-dirs.defaults and $HOME/.config/user-dirs.default
</description>
<default>[ '$HOME' ]</default>
</key>
<key name="ignored-files" type="as">
<summary>Ignored files</summary>
<description>List of file patterns to avoid</description>
<default>[ '*~', '*.o', '*.la', '*.lo' , '*.loT', '*.in', '*.csproj', '*.m4', '*.rej', '*.gmo', '*.orig', '*.pc', '*.omf', '*.aux', '*.tmp', '*.vmdk', '*.vm*', '*.nvram', '*.part', '*.rcore', '*.lzo', 'autom4te', 'conftest', 'confstat', 'Makefile', 'SCCS', 'ltmain.sh', 'libtool', 'config.status', 'confdefs.h', 'configure', '#*#', '~$*.doc?', '~$*.dot?', '~$*.xls?', '~$*.xlt?', '~$*.xlam', '~$*.ppt?', '~$*.pot?', '~$*.ppam', '~$*.ppsm', '~$*.ppsx', '~$*.vsd?', '~$*.vss?', '~$*.vst?', 'mimeapps.list', 'mimeinfo.cache', 'gnome-mimeapps.list', 'kde-mimeapps.list', '*.directory' ]</default>
</key>
<key name="ignored-directories" type="as">
<summary>Ignored directories</summary>
<description>List of directories to avoid</description>
<default>[ 'po', 'CVS', 'core-dumps', 'lost+found' ]</default>
</key>
<key name="ignored-directories-with-content" type="as">
<summary>Ignored directories with content</summary>
<description>Avoid any directory containing a file blacklisted here</description>
<default>[ '.trackerignore', '.git', '.hg' ]</default>
</key>
</schema>
</schemalist>
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<schemalist>
<schema id="org.freedesktop.Tracker.Writeback" path="/org/freedesktop/tracker/writeback/" gettext-domain="tracker-miners">
<key name="verbosity" enum="org.freedesktop.TrackerMiners.TrackerVerbosity">
<default>'errors'</default>
<summary>Log verbosity</summary>
<description>Log verbosity.</description>
</key>
</schema>
</schemalist>
......@@ -379,6 +379,7 @@ tracker_miner_services_dir = join_paths(get_option('prefix'), get_option('datadi
tracker_writeback_modules_dir = join_paths(get_option('prefix'), get_option('libdir'), 'tracker-miners-@0@/writeback-modules'.format(tracker_api_version))
tracker_uninstalled_extract_rules_dir = join_paths(meson.current_build_dir(), 'src', 'tracker-extract')
tracker_uninstalled_writeback_modules_dir = join_paths(meson.current_build_dir(), 'src', 'tracker-writeback')
gsettings_schema_dir = join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')
vapi_dir = join_paths(get_option('prefix'), get_option('datadir'), 'vala', 'vapi')
......@@ -386,6 +387,7 @@ vapi_dir = join_paths(get_option('prefix'), get_option('datadir'), 'vala', 'vapi
glib_mkenums = find_program('glib-mkenums')
subdir('src')
subdir('data')
if get_option('docs')
subdir('docs')
......
......@@ -58,9 +58,6 @@ desktop_file = custom_target('tracker-miner-fs-desktop-file',
install: true,
install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
install_data('org.freedesktop.Tracker.Miner.Files.gschema.xml',
install_dir: gsettings_schema_dir)
if install_systemd_user_services
configure_file(
input: 'tracker-miner-fs.service.in',
......
......@@ -198,9 +198,6 @@ desktop_file = custom_target('tracker-extract-desktop-file',
install: true,
install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
install_data('org.freedesktop.Tracker.Extract.gschema.xml',
install_dir: gsettings_schema_dir)
if install_systemd_user_services
configure_file(
input: 'tracker-extract.service.in',
......
......@@ -56,9 +56,6 @@ dbus_service_file = configure_file(
install: true,
install_dir: dbus_services_dir)
install_data('org.freedesktop.Tracker.Writeback.gschema.xml',
install_dir: gsettings_schema_dir)
if install_systemd_user_services
configure_file(
input: 'tracker-writeback.service.in',
......
......@@ -49,11 +49,19 @@ static gboolean
writeback_module_load (GTypeModule *module)
{
TrackerWritebackModule *writeback_module;
const gchar *writeback_modules_dir;
gchar *path;
writeback_module = TRACKER_WRITEBACK_MODULE (module);
path = g_build_filename (WRITEBACK_MODULES_DIR, writeback_module->name, NULL);
writeback_modules_dir = g_getenv("TRACKER_WRITEBACK_MODULES_DIR");
if (G_LIKELY (writeback_modules_dir == NULL)) {
writeback_modules_dir = WRITEBACK_MODULES_DIR;
} else {
g_message ("Writeback modules directory is '%s' (set in env)", writeback_modules_dir);
}
path = g_build_filename (writeback_modules_dir, writeback_module->name, NULL);
writeback_module->module = g_module_open (path, G_MODULE_BIND_LOCAL);
g_free (path);
......@@ -129,11 +137,18 @@ GList *
tracker_writeback_modules_list (void)
{
GError *error = NULL;
const gchar *name;
const gchar *writeback_modules_dir, *name;
GList *list = NULL;
GDir *dir;
dir = g_dir_open (WRITEBACK_MODULES_DIR, 0, &error);
writeback_modules_dir = g_getenv("TRACKER_WRITEBACK_MODULES_DIR");
if (G_LIKELY (writeback_modules_dir == NULL)) {
writeback_modules_dir = WRITEBACK_MODULES_DIR;
} else {
g_message ("Writeback modules directory is '%s' (set in env)", writeback_modules_dir);
}
dir = g_dir_open (writeback_modules_dir, 0, &error);
if (error) {
g_critical ("Could not get writeback modules list: %s", error->message);
......
......@@ -33,7 +33,7 @@ import unittest as ut
from common.utils.helpers import log
from common.utils.minertest import CommonTrackerMinerTest
NFO_TEXT_DOCUMENT = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument'
NFO_DOCUMENT = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document'
class MinerCrawlTest (CommonTrackerMinerTest):
"""
......@@ -74,8 +74,6 @@ class MinerCrawlTest (CommonTrackerMinerTest):
"""
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]
......@@ -96,11 +94,11 @@ class MinerCrawlTest (CommonTrackerMinerTest):
Copy an file from unmonitored directory to monitored directory
and verify if data base is updated accordingly
"""
source = os.path.join (self.datadir, "test-no-monitored", "file0.txt")
dest = os.path.join (self.datadir, "test-monitored", "file0.txt")
source = os.path.join (self.workdir, "test-no-monitored", "file0.txt")
dest = os.path.join (self.workdir, "test-monitored", "file0.txt")
shutil.copyfile (source, dest)
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(dest))
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(dest))
# verify if miner indexed this file.
result = self.__get_text_documents ()
......@@ -114,7 +112,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# 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)
self.system.store.await_resource_deleted (NFO_DOCUMENT, dest_id)
def test_03_copy_from_monitored_to_unmonitored (self):
"""
......@@ -123,8 +121,8 @@ class MinerCrawlTest (CommonTrackerMinerTest):
"""
# Copy from monitored to unmonitored
source = os.path.join (self.datadir, "test-monitored", "file1.txt")
dest = os.path.join (self.datadir, "test-no-monitored", "file1.txt")
source = os.path.join (self.workdir, "test-monitored", "file1.txt")
dest = os.path.join (self.workdir, "test-no-monitored", "file1.txt")
shutil.copyfile (source, dest)
time.sleep (1)
......@@ -143,11 +141,11 @@ class MinerCrawlTest (CommonTrackerMinerTest):
"""
Copy a file between monitored directories
"""
source = os.path.join (self.datadir, "test-monitored", "file1.txt")
dest = os.path.join (self.datadir, "test-monitored", "dir1", "dir2", "file-test04.txt")
source = os.path.join (self.workdir, "test-monitored", "file1.txt")
dest = os.path.join (self.workdir, "test-monitored", "dir1", "dir2", "file-test04.txt")
shutil.copyfile (source, dest)
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(dest))
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(dest))
result = self.__get_text_documents ()
self.assertEquals (len (result), 4)
......@@ -159,7 +157,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Clean the file
os.remove (dest)
self.system.store.await_resource_deleted (dest_id)
self.system.store.await_resource_deleted (NFO_DOCUMENT, dest_id)
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
......@@ -167,10 +165,10 @@ class MinerCrawlTest (CommonTrackerMinerTest):
"""
Move a file from unmonitored to monitored directory
"""
source = os.path.join (self.datadir, "test-no-monitored", "file0.txt")
dest = os.path.join (self.datadir, "test-monitored", "dir1", "file-test05.txt")
source = os.path.join (self.workdir, "test-no-monitored", "file0.txt")
dest = os.path.join (self.workdir, "test-monitored", "dir1", "file-test05.txt")
shutil.move (source, dest)
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(dest))
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(dest))
result = self.__get_text_documents ()
self.assertEquals (len (result), 4)
......@@ -182,7 +180,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Clean the file
os.remove (dest)
self.system.store.await_resource_deleted (dest_id)
self.system.store.await_resource_deleted (NFO_DOCUMENT, dest_id)
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
## """ move operation and tracker-miner response test cases """
......@@ -197,7 +195,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
dest = self.path("test-no-monitored/file2.txt")
source_id = self.system.store.get_resource_id (self.uri(source))
shutil.move (source, dest)
self.system.store.await_resource_deleted (source_id)
self.system.store.await_resource_deleted (NFO_DOCUMENT, source_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 2)
......@@ -207,7 +205,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Restore the file
shutil.move (dest, source)
self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(source))
self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(source))
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
......@@ -226,7 +224,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
self.assertEquals (source_dir_urn, parent_before)
shutil.move (source, dest)
self.tracker.await_property_changed(resource_id, 'nie:url')
self.tracker.await_property_changed(NFO_DOCUMENT, resource_id, 'nie:url')
# Checking fix for NB#214413: After a move operation, nfo:belongsToContainer
# should be changed to the new one
......@@ -244,7 +242,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Restore the file
shutil.move (dest, source)
self.tracker.await_property_changed(resource_id, 'nie:url')
self.tracker.await_property_changed(NFO_DOCUMENT, resource_id, 'nie:url')
result = self.__get_text_documents ()
self.assertEquals (len (result), 3)
......@@ -259,7 +257,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
victim = self.path("test-monitored/dir1/file2.txt")
victim_id = self.system.store.get_resource_id (self.uri(victim))
os.remove (victim)
self.system.store.await_resource_deleted (victim_id)
self.system.store.await_resource_deleted (NFO_DOCUMENT, victim_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 2)
......@@ -271,7 +269,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
f = open (victim, "w")
f.write ("Don't panic, everything is fine")
f.close ()
self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(victim))
self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(victim))
def test_09_deletion_directory (self):
"""
......@@ -283,7 +281,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
file_inside_victim_url = self.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)
self.system.store.await_resource_deleted (NFO_DOCUMENT, file_inside_victim_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 1)
......@@ -299,7 +297,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
writer = open (filename, "w")
writer.write ("Don't panic, everything is fine")
writer.close ()
self.system.store.await_resource_inserted (NFO_TEXT_DOCUMENT, self.uri(f))
self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(f))
# Check everything is fine
result = self.__get_text_documents ()
......
......@@ -77,12 +77,12 @@ class MinerResourceRemovalTest (CommonTrackerMinerTest):
os.unlink (self.path ("test-monitored/test_1.txt"))
self.tracker.await_resource_deleted (NFO_DOCUMENT, file_1_id)
self.tracker.await_resource_deleted (NFO_DOCUMENT, ie_1_id,
"Associated logical resource failed to be deleted " \
"when its containing file was removed.")
self.assertResourceMissing (file_1_urn)
# Ensure the logical resource is deleted when the relevant file is
# removed.
self.assertResourceMissing (ie_1_urn)
self.assertResourceExists (file_2_urn)
self.assertResourceExists (ie_2_urn)
......
......@@ -37,7 +37,7 @@ from common.utils.minertest import CommonTrackerMinerFTSTest, DEFAULT_TEXT
from common.utils import configuration as cfg
NFO_TEXT_DOCUMENT = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument'
NFO_DOCUMENT = 'http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document'
class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
......@@ -54,7 +54,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
id = self._query_id (self.uri (self.testfile))
os.remove (self.path (self.testfile))
self.tracker.await_resource_deleted (NFO_TEXT_DOCUMENT, id)
self.tracker.await_resource_deleted (NFO_DOCUMENT, id)
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
......@@ -128,7 +128,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
self.assertEquals (len (results), 0)
shutil.copyfile (self.path (TEST_16_SOURCE), self.path (TEST_16_DEST))
self.tracker.await_resource_inserted (rdf_class = NFO_TEXT_DOCUMENT,
self.tracker.await_resource_inserted (rdf_class = NFO_DOCUMENT,
url = self.uri(TEST_16_DEST),
required_property = 'nie:plainTextContent')
......
......@@ -47,18 +47,9 @@ VALID_FILE_TITLE = 'Simply Juvenile'
TRACKER_EXTRACT_FAILURE_DATA_SOURCE = 'tracker:extractor-failure-data-source'
def ensure_dir_exists(dirname):
if not os.path.exists(dirname):
os.makedirs(dirname)
class ExtractorDecoratorTest(ut.TestCase):
def setUp(self):
ensure_dir_exists(cfg.TEST_MONITORED_TMP_DIR)
# It's important that this directory is NOT inside /tmp, because
# monitoring files in /tmp usually doesn't work.
self.datadir = tempfile.mkdtemp(dir=cfg.TEST_MONITORED_TMP_DIR)
self.datadir = cfg.create_monitored_test_dir()
config = {
cfg.DCONF_MINER_SCHEMA: {
......@@ -76,9 +67,9 @@ class ExtractorDecoratorTest(ut.TestCase):
self.system.tracker_miner_fs_testing_start()
def tearDown(self):
self.system.tracker_miner_fs_testing_stop()
self.system.finish()
shutil.rmtree(self.datadir)
cfg.remove_monitored_test_dir(self.datadir)
def test_reextraction(self):
"""Tests whether known files are still re-extracted on user request."""
......@@ -110,6 +101,8 @@ class ExtractorDecoratorTest(ut.TestCase):
assert len(title_result) == 1
self.assertEqual(title_result[0][0], VALID_FILE_TITLE)
os.remove(file_path)
if __name__ == '__main__':
ut.main()
......@@ -28,7 +28,6 @@ from common.utils.extractor import get_tracker_extract_jsonld_output
from common.utils.helpers import log
from common.utils.writebacktest import CommonTrackerWritebackTest as CommonTrackerWritebackTest
import unittest as ut
from common.utils.expectedFailure import expectedFailureBug
REASONABLE_TIMEOUT = 5 # Seconds we wait for tracker-writeback to do the work
......@@ -37,28 +36,6 @@ 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):
"""
......@@ -77,11 +54,11 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
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.__clean_property (prop, filename)
self.tracker.update (SPARQL_TMPL % (prop, TEST_VALUE, filename))
self.tracker.update (SPARQL_TMPL % (prop, filename, prop, prop, TEST_VALUE, filename))
log("Waiting for change on %s" % filename_real)
self.wait_for_file_change(filename_real, initial_mtime)
......@@ -90,8 +67,6 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
results = get_tracker_extract_jsonld_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):
......@@ -132,14 +107,14 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
#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_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")
#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
......@@ -151,37 +126,33 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
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"