[tracker-miners/sam/test-runner-fix: 16/21] functional-tests: Run each writeback test in a clean environment
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/sam/test-runner-fix: 16/21] functional-tests: Run each writeback test in a clean environment
- Date: Mon, 11 Feb 2019 00:03:34 +0000 (UTC)
commit 8310482cb51109f23518c6eb3ff39a82a81b1f56
Author: Sam Thursfield <sam afuera me uk>
Date: Fri Jan 4 22:50:28 2019 +0100
functional-tests: Run each writeback test in a clean environment
This way it's slower, but prevents the tests from mostly failing.
tests/functional-tests/500-writeback.py | 28 ++--------------------
tests/functional-tests/501-writeback-details.py | 3 +--
.../functional-tests/common/utils/writebacktest.py | 15 ++++++------
3 files changed, 10 insertions(+), 36 deletions(-)
---
diff --git a/tests/functional-tests/500-writeback.py b/tests/functional-tests/500-writeback.py
index f82bd8b42..eebef54c9 100755
--- a/tests/functional-tests/500-writeback.py
+++ b/tests/functional-tests/500-writeback.py
@@ -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):
diff --git a/tests/functional-tests/501-writeback-details.py b/tests/functional-tests/501-writeback-details.py
index 2ab90ccef..83a5518c6 100755
--- a/tests/functional-tests/501-writeback-details.py
+++ b/tests/functional-tests/501-writeback-details.py
@@ -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):
diff --git a/tests/functional-tests/common/utils/writebacktest.py
b/tests/functional-tests/common/utils/writebacktest.py
index ebfeeb92a..674e0febf 100644
--- a/tests/functional-tests/common/utils/writebacktest.py
+++ b/tests/functional-tests/common/utils/writebacktest.py
@@ -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 ():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]