Commit f919fd40 authored by Sam Thursfield's avatar Sam Thursfield

functional-tests: Await nfo:Document rather than nfo:TextDocument

The latter class doesn't have the tracker:notify property set, so we
were not getting any insert notifactions and all the 300-* miner tests
were failing.

This also fixes missing parameters in other await_* calls. The errors
were being masked by the first failure.
parent dc43f8c5
......@@ -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):
"""
......@@ -98,7 +98,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
dest = os.path.join (self.datadir, "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 ()
......@@ -112,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):
"""
......@@ -145,7 +145,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
dest = os.path.join (self.datadir, "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)
......@@ -157,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"))
......@@ -168,7 +168,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
source = os.path.join (self.datadir, "test-no-monitored", "file0.txt")
dest = os.path.join (self.datadir, "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)
......@@ -180,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 """
......@@ -195,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)
......@@ -205,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"))
......@@ -224,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
......@@ -242,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)
......@@ -257,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)
......@@ -269,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):
"""
......@@ -281,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)
......@@ -297,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 ()
......
......@@ -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')
......
......@@ -33,7 +33,7 @@ from itertools import chain
DEFAULT_TEXT = "Some stupid content, to have a test file"
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'
def ensure_dir_exists(dirname):
......@@ -117,7 +117,7 @@ class CommonTrackerMinerTest (ut.TestCase):
f.write (DEFAULT_TEXT)
for tf in monitored_files:
self.tracker.await_resource_inserted(NFO_TEXT_DOCUMENT, url=self.uri(tf))
self.tracker.await_resource_inserted(NFO_DOCUMENT, url=self.uri(tf))
def remove_test_data(self):
try:
......@@ -156,11 +156,11 @@ class CommonTrackerMinerFTSTest (CommonTrackerMinerTest):
if exists:
subject_id = self.tracker.get_resource_id(self.uri(self.testfile))
self.tracker.await_property_changed(NFO_TEXT_DOCUMENT,
self.tracker.await_property_changed(NFO_DOCUMENT,
subject_id=subject_id, property_uri='nie:plainTextContent')
else:
self.tracker.await_resource_inserted(
rdf_class=NFO_TEXT_DOCUMENT, url=self.uri(self.testfile),
rdf_class=NFO_DOCUMENT, url=self.uri(self.testfile),
required_property='nie:plainTextContent')
self.tracker.reset_graph_updates_tracking()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment