[tracker] functional-tests: Fail instead of error when gstreamer plugin not preset. Handle correctly nao:Tags.
- From: Ivan Frade <ifrade src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] functional-tests: Fail instead of error when gstreamer plugin not preset. Handle correctly nao:Tags.
- Date: Wed, 24 Aug 2011 14:22:25 +0000 (UTC)
commit 162785aa7242a566f362e121d91b0e1ac3df19aa
Author: Ivan Frade <ivan frade gmail com>
Date: Wed Aug 24 17:17:59 2011 +0300
functional-tests: Fail instead of error when gstreamer plugin not preset. Handle correctly nao:Tags.
tests/functional-tests/400-extractor.py | 10 +++-
tests/functional-tests/common/utils/helpers.py | 42 +++++++++++++++----
tests/functional-tests/test-extraction-data/README | 5 ++-
.../images/test-image-1.expected | 4 +-
.../images/xmp-loaded-1.expected | 6 +-
5 files changed, 49 insertions(+), 18 deletions(-)
---
diff --git a/tests/functional-tests/400-extractor.py b/tests/functional-tests/400-extractor.py
index 039094f..ff4f52d 100755
--- a/tests/functional-tests/400-extractor.py
+++ b/tests/functional-tests/400-extractor.py
@@ -23,7 +23,7 @@ metadata is extracted. Load dynamically the test information from a data
directory (containing xxx.expected files)
"""
from common.utils import configuration as cfg
-from common.utils.helpers import ExtractorHelper
+from common.utils.helpers import ExtractorHelper, NoMetadataException
import unittest2 as ut
import os
import types
@@ -118,9 +118,13 @@ class ExtractionTestCase (ut.TestCase):
except Exception, e:
self.fail ("%s in %s"
% (e, abs_description))
- result = self.extractor.get_metadata ("file://" + self.file_to_extract, "")
- self.__assert_extraction_ok (result)
+ try:
+ result = self.extractor.get_metadata ("file://" + self.file_to_extract, "")
+
+ self.__assert_extraction_ok (result)
+ except NoMetadataException, e:
+ self.fail ("Probably a missing gstreamer plugin (or crash in the extractor?)")
def assertDictHasKey (self, d, key, msg=None):
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index dff8185..e6dc1c4 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -26,6 +26,9 @@ from dbus.mainloop.glib import DBusGMainLoop
import configuration as cfg
import re
+class NoMetadataException (Exception):
+ pass
+
class StoreHelper:
"""
Wrapper for the Store API
@@ -178,15 +181,22 @@ class ExtractorHelper ():
}
"""
metadata = {}
- preupdate, embedded, where = self.extractor.GetMetadata (filename, mime)
- for attribute_value in self.__process_lines (embedded):
- att, value = attribute_value.split (" ", 1)
- if metadata.has_key (att):
- metadata [att].append (value)
- else:
- metadata [att] = [value]
-
- return metadata
+ try:
+ preupdate, embedded, where = self.extractor.GetMetadata (filename, mime)
+ extras = self.__process_where_part (where)
+ for attribute_value in self.__process_lines (embedded):
+ att, value = attribute_value.split (" ", 1)
+ if value.startswith ("?") and extras.has_key (value):
+ value = extras[value]
+
+ if metadata.has_key (att):
+ metadata [att].append (value)
+ else:
+ metadata [att] = [value]
+
+ return metadata
+ except dbus.DBusException, e:
+ raise NoMetadataException ()
def __process_lines (self, embedded):
"""
@@ -228,6 +238,20 @@ class ExtractorHelper ():
return map (self.__clean_value, grouped_lines)
+ def __process_where_part (self, where):
+ gettags = re.compile ("(\?\w+)\ a\ nao:Tag\ ;\ nao:prefLabel\ \"([\w\ -]+)\"")
+ tags = {}
+ for l in where.split ("\n"):
+ if len (l) == 0:
+ continue
+ match = gettags.search (l)
+ if (match):
+ tags [match.group(1)] = match.group (2)
+ else:
+ print "This line is not a tag:", l
+
+ return tags
+
def __handle_multivalues (self, line):
"""
Split multivalues like:
diff --git a/tests/functional-tests/test-extraction-data/README b/tests/functional-tests/test-extraction-data/README
index ae8d3dc..1a3e215 100644
--- a/tests/functional-tests/test-extraction-data/README
+++ b/tests/functional-tests/test-extraction-data/README
@@ -43,7 +43,10 @@ The Metadata section contains pairs of property=values with few special rules:
It handles a couple of special cases, relevant for testing:
E.G.
- nao:hasTag [a nao:Tag; nao:prefLabel "XXX"] -> nao_hasTag_prefLabel=XXX
+ slo:location [a slo:GeoLocation; slo:PostalAddress "XXX"] -> slo_location_postalAddress=XXX
+
+ Note 24/08/2011: Tags are translated as "nao_Tag=value, value, value" instead of
+ the old "nao_Tag_preflabel=value, value, value"
5. There is (so far only) one constant defined to use in the values:
diff --git a/tests/functional-tests/test-extraction-data/images/test-image-1.expected b/tests/functional-tests/test-extraction-data/images/test-image-1.expected
index 03b142d..64a11a7 100644
--- a/tests/functional-tests/test-extraction-data/images/test-image-1.expected
+++ b/tests/functional-tests/test-extraction-data/images/test-image-1.expected
@@ -7,8 +7,8 @@ Comment=Basic jpeg example
a=nmm:Photo
nfo_width=699
nfo_height=464
-nao_hasTag_prefLabel=test
-nao_hasTag_prefLabel=tracker
+nao_hasTag=test
+nao_hasTag=tracker
nie_title=Kid
nmm_fnumber=5
nmm_focalLength=5
diff --git a/tests/functional-tests/test-extraction-data/images/xmp-loaded-1.expected b/tests/functional-tests/test-extraction-data/images/xmp-loaded-1.expected
index a59ce59..cb3d099 100644
--- a/tests/functional-tests/test-extraction-data/images/xmp-loaded-1.expected
+++ b/tests/functional-tests/test-extraction-data/images/xmp-loaded-1.expected
@@ -8,9 +8,9 @@ a=nfo:Image
a=nmm:Photo
nie_description=Test file for the tracker XMP extraction
nie_title=A random GIF
-nao_hasTag_prefLabel=Cool
-nao_hasTag_prefLabel=favourite
-nao_hasTag_prefLabel=nice
+nao_hasTag=Cool
+nao_hasTag=favourite
+nao_hasTag=nice
dc_identifier=test-file-01-world-domination-path
dc_source=http://www.fotonatura.org/revista/articulos/293/3/
dc_language=es_ES
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]