summaryrefslogtreecommitdiff
path: root/tests/functional-tests/500-writeback.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional-tests/500-writeback.py')
-rwxr-xr-xtests/functional-tests/500-writeback.py121
1 files changed, 65 insertions, 56 deletions
diff --git a/tests/functional-tests/500-writeback.py b/tests/functional-tests/500-writeback.py
index cdd2b06ab..1fc52aa59 100755
--- a/tests/functional-tests/500-writeback.py
+++ b/tests/functional-tests/500-writeback.py
@@ -21,7 +21,8 @@
Write values in tracker and check the actual values are written
on the files. Note that these tests are highly platform dependant.
"""
-import os, dbus
+import os
+import dbus
import time
from common.utils.extractor import get_tracker_extract_output
@@ -29,18 +30,21 @@ from common.utils.writebacktest import CommonTrackerWritebackTest as CommonTrack
import unittest2 as ut
from common.utils.expectedFailure import expectedFailureBug
-REASONABLE_TIMEOUT = 5 # Seconds we wait for tracker-writeback to do the work
+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):
+
+ def setUp(self):
self.tracker = self.system.store
self.extractor = self.system.extractor
- def __clean_property (self, property_name, fileuri, expectFailure=True):
+ def __clean_property(self, property_name, fileuri, expectFailure=True):
"""
Remove the property for the fileuri (file://...)
"""
@@ -53,13 +57,13 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
}
"""
try:
- self.tracker.update (CLEAN % (property_name, fileuri, property_name))
+ 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):
+ 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.
@@ -74,23 +78,22 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
filename_real = filename[len('file://'):]
initial_mtime = os.stat(filename_real).st_mtime
- TEST_VALUE = prop.replace (":","") + "test"
+ 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.__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)
+ results = get_tracker_extract_output(filename, mimetype)
keyDict = expectedKey or prop
- self.assertIn (TEST_VALUE, results[keyDict])
- self.__clean_property (prop, filename, False)
-
+ self.assertIn(TEST_VALUE, results[keyDict])
+ self.__clean_property(prop, filename, False)
- def __writeback_hasTag_test (self, filename, mimetype):
+ def __writeback_hasTag_test(self, filename, mimetype):
SPARQL_TMPL = """
INSERT {
@@ -112,73 +115,79 @@ class WritebackBasicDataTest (CommonTrackerWritebackTest):
}
"""
- self.tracker.update (SPARQL_TMPL % (filename))
-
- time.sleep (REASONABLE_TIMEOUT)
+ self.tracker.update(SPARQL_TMPL % (filename))
- results = get_tracker_extract_output (filename, mimetype)
- self.assertIn ("testTag", results ["nao:hasTag"])
+ 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):
+ 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")
+ self.__writeback_test(
+ self.get_test_filename_jpeg(), "image/jpeg", "nie:title")
- def test_002_jpeg_description (self):
+ 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")
+ self.__writeback_test(
+ self.get_test_filename_jpeg(), "image/jpeg", "nie:description")
- def test_003_jpeg_keyword (self):
+ 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")
+ self.__writeback_test(self.get_test_filename_jpeg(), "image/jpeg",
+ "nie:keyword", "nao:hasTag")
- def test_004_jpeg_hasTag (self):
+ 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")
+ self.__writeback_hasTag_test(
+ self.get_test_filename_jpeg(), "image/jpeg")
-
# TIFF tests
- def test_011_tiff_title (self):
+ 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")
+ self.__writeback_test(
+ self.get_test_filename_tiff(), "image/tiff", "nie:title")
- def test_012_tiff_description (self):
+ 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):
+ 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")
+ self.__writeback_test(self.get_test_filename_tiff(), "image/tiff",
+ "nie:keyword", "nao:hasTag")
- def test_014_tiff_hasTag (self):
+ 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")
-
-
+ self.__writeback_hasTag_test(
+ self.get_test_filename_tiff(), "image/tiff")
# PNG tests
- @expectedFailureBug ("NB#185070")
- def test_021_png_title (self):
+ @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")
+ self.__writeback_test(
+ self.get_test_filaname_png(), "image/png", "nie:title")
- @expectedFailureBug ("NB#185070")
- def test_022_png_description (self):
+ @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):
+ 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")
+ self.__writeback_test(
+ self.get_test_filaname_png(), "image/png", "nie:keyword", "nao:hasTag:prefLabel")
@expectedFailureBug("NB#185070")
- def test_024_png_hasTag (self):
+ 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")
+ self.__writeback_hasTag_test(
+ self.get_test_filaname_png(), "image/png")
if __name__ == "__main__":
- ut.main ()
+ ut.main()