Commit 8310482c authored by Sam Thursfield's avatar Sam Thursfield

functional-tests: Run each writeback test in a clean environment

This way it's slower, but prevents the tests from mostly failing.
parent 5d561091
......@@ -37,28 +37,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 +55,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 +68,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):
......
......@@ -31,8 +31,7 @@ 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
super(WritebackKeepDateTest, self).setUp()
self.favorite = self.__prepare_favorite_tag ()
def __prepare_favorite_tag (self):
......
......@@ -58,8 +58,7 @@ class CommonTrackerWritebackTest (ut.TestCase):
Superclass to share methods. Shouldn't be run by itself.
Start all processes including writeback, miner pointing to WRITEBACK_TMP_DIR
"""
@classmethod
def __prepare_directories (self):
if (os.path.exists (os.getcwd() + "/test-writeback-data")):
# Use local directory if available
......@@ -80,8 +79,7 @@ class CommonTrackerWritebackTest (ut.TestCase):
shutil.copy (origin, WRITEBACK_TMP_DIR)
@classmethod
def setUpClass (self):
def setUp(self):
#print "Starting the daemon in test mode"
self.__prepare_directories ()
......@@ -100,15 +98,16 @@ class CommonTrackerWritebackTest (ut.TestCase):
await_resource_extraction (self.get_test_filename_tiff())
await_resource_extraction (self.get_test_filename_png())
self.tracker = self.system.store
self.extractor = self.system.extractor
# Returns when ready
log ("Ready to go!")
@classmethod
def tearDownClass (self):
def tearDown (self):
#print "Stopping the daemon in test mode (Doing nothing now)"
self.system.tracker_writeback_testing_stop ()
log ("Test finished")
@staticmethod
def get_test_filename_jpeg ():
......
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