[tracker] functional-tests: Update test cases
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] functional-tests: Update test cases
- Date: Thu, 11 Mar 2010 13:36:02 +0000 (UTC)
commit 6a6cdfb77684a528798de9f83a2c61dd5858992c
Author: Amit Jain <ext-amit 1 jain nokia com>
Date: Thu Mar 11 14:34:32 2010 +0100
functional-tests: Update test cases
Correction in dates related test scripts and use of macros instead
of hardcoded items.
tests/functional-tests/01-insertion.py | 106 +++++++++-------------------
tests/functional-tests/virtual-files-tc.py | 11 ++--
tests/functional-tests/writeback-tc.py | 45 ++++++------
3 files changed, 64 insertions(+), 98 deletions(-)
---
diff --git a/tests/functional-tests/01-insertion.py b/tests/functional-tests/01-insertion.py
index 3ed45a2..8c6998e 100755
--- a/tests/functional-tests/01-insertion.py
+++ b/tests/functional-tests/01-insertion.py
@@ -254,9 +254,14 @@ class s_insert(TestUpdate):
INSERT { <%s> a nie:InformationElement;
nie:informationElementDate "204-05-06T13:14:15+0400". }
""" % (uri)
- self.sparql_update (insert)
+ try :
+ self.resources.SparqlUpdate(insert)
- """ verify the inserted item """
+ except :
+ print "error in query execution"
+ self.assert_(True,'error in query execution')
+
+ """ verify whether the item is inserted"""
query = 'SELECT ?s fn:year-from-dateTime (?v) \
fn:month-from-dateTime (?v) \
@@ -347,7 +352,7 @@ class s_insert(TestUpdate):
for i in range(len(result)):
if result[i][0] == 'tracker:test_date_04':
- if result[i][1] == '2004' and result[i][2] == '05' and result[i][3] == '06' and result[i][4] == '13' and result[i][5] == '14' and result[i][6] == '15' and result[i][7] == '0' :
+ if result[i][1] == '2004' and result[i][2] == '05' and result[i][3] == '06' and result[i][4] == '13' and result[i][5] == '14' and result[i][6] == '15':
self.assert_(True,'Pass')
else:
self.fail('Fail %s' %result)
@@ -365,29 +370,16 @@ class s_insert(TestUpdate):
INSERT { <%s> a nie:InformationElement;
nie:informationElementDate "2004-05-06". }
""" % (uri)
- self.sparql_update (insert)
+ try :
+ self.resources.SparqlUpdate(insert)
- """ verify the inserted item """
-
- query = 'SELECT ?s fn:year-from-dateTime (?v) \
- fn:month-from-dateTime (?v) \
- fn:day-from-dateTime (?v) \
- fn:hours-from-dateTime (?v) \
- fn:minutes-from-dateTime (?v) \
- fn:seconds-from-dateTime (?v) \
- fn:timezone-from-dateTime (?v) \
- WHERE { ?s a nie:InformationElement; \
- nie:informationElementDate ?v . \
- }'
- result = self.query (query)
- print result
+ except :
+ print "error in query execution"
+ self.assert_(True,'error in query execution')
- for i in range(len(result)):
- if result[i][1] == '2004' and result[i][2] == '05' and result[i][3] == '06':
- self.assert_(True,'Pass')
- else:
- print result[i]
- self.fail('Fail %s' %result)
+ else:
+ self.fail('Query successfully executed')
+
def test_insert_date_06(self):
@@ -401,30 +393,17 @@ class s_insert(TestUpdate):
INSERT { <%s> a nie:InformationElement;
nie:informationElementDate "2004-05-06T". }
""" % (uri)
- self.sparql_update (insert)
- """ verify the inserted item """
+ try :
+ self.resources.SparqlUpdate(insert)
- query = 'SELECT ?s fn:year-from-dateTime (?v) \
- fn:month-from-dateTime (?v) \
- fn:day-from-dateTime (?v) \
- fn:hours-from-dateTime (?v) \
- fn:minutes-from-dateTime (?v) \
- fn:seconds-from-dateTime (?v) \
- fn:timezone-from-dateTime (?v) \
- WHERE { ?s a nie:InformationElement; \
- nie:informationElementDate ?v . \
- }'
- result = self.query (query)
- print result
+ except :
+ print "error in query execution"
+ self.assert_(True,'error in query execution')
- for i in range(len(result)):
- if result[i][0] == 'tracker:test_date_06':
- if result[i][1] == '2004' and result[i][2] == '05' and result[i][3] == '06' :
- self.assert_(True,'Pass')
- else:
- print result[i]
- self.fail('Fail %s' %result)
+ else:
+ self.fail('Query successfully executed')
+
def test_insert_date_07(self):
@@ -512,32 +491,17 @@ class s_insert(TestUpdate):
INSERT { <%s> a nie:InformationElement;
nie:informationElementDate "2004-05-06T1g:14:15-0200". }
""" % (uri)
- self.sparql_update (insert)
-
- """ verify the inserted item """
-
- query = 'SELECT ?s fn:year-from-dateTime (?v) \
- fn:month-from-dateTime (?v) \
- fn:day-from-dateTime (?v) \
- fn:hours-from-dateTime (?v) \
- fn:minutes-from-dateTime (?v) \
- fn:seconds-from-dateTime (?v) \
- fn:timezone-from-dateTime (?v) \
- WHERE { ?s a nie:InformationElement; \
- nie:informationElementDate ?v . \
- }'
- result = self.query (query)
-
- for i in range(len(result)):
- if result[i][0] == 'tracker:test_date_09':
- if result[i][1] == '2004' and result[i][2] == '05' and result[i][3] == '06' and result[i][5] == '14' and result[i][6] == '15' and result[i][7] == '-9000':
- self.assert_(True,'Pass')
- else:
- print result[i]
- self.fail('Fail %s' %result)
+ try :
+ self.resources.SparqlUpdate(insert)
+ except :
+ print "error in query execution"
+ self.assert_(True,'error in query execution')
+ else:
+ self.fail('Query successfully executed')
+
""" Deletion test cases """
class s_delete(TestUpdate):
@@ -625,12 +589,12 @@ class s_delete(TestUpdate):
"""Delete the added music album """
- #self.sparql_update('DELETE { \
- #<6_Album_delete> a nmm:MusicAlbum.}')
+ self.sparql_update('DELETE { \
+ <06_Album_delete> a nmm:MusicAlbum.}')
"""get the count of music albums"""
result = self.query('SELECT ?album WHERE { \
- ?albuumm a nmm:MusicAlbum. \
+ ?album a nmm:MusicAlbum. \
} ')
count_after_del = len(result)
diff --git a/tests/functional-tests/virtual-files-tc.py b/tests/functional-tests/virtual-files-tc.py
index 8b508be..ac064c0 100644
--- a/tests/functional-tests/virtual-files-tc.py
+++ b/tests/functional-tests/virtual-files-tc.py
@@ -33,17 +33,17 @@ MINER_IFACE="org.freedesktop.Tracker1.Miner"
target = configuration.check_target()
if target == '2' :
- dir_path = os.environ['HOME'] + '/MyDocs'
- dir_path_parent = os.environ['HOME']
+ dir_path = '/home/user/MyDocs'
+ dir_path_parent = '/home/user'
else :
- dir_path = sys.prefix + '/share/tracker-tests/data'
- dir_path_parent = sys.prefix + '/share/tracker-tests'
+ dir_path = configuration.TEST_DATA_DIR
+ dir_path_parent = configuration.TEST_DIR
print dir_path
""" copy the test data to proper location. """
def copy_file():
- src = sys.prefix + '/share/tracker-tests/data/Images/test-image-1.jpg'
+ src = configuration.TEST_DATA_IMAGES + 'test-image-1.jpg'
dest = dir_path
print 'Copying '+src+' to '+dest
commands.getoutput('cp '+src+ ' '+dest)
@@ -83,7 +83,6 @@ class virtual_files(TestVirtualFiles):
uri='file://' + file
print uri
- time.sleep(10)
commands.getoutput('mv ' + file + ' ' + dir_path_parent)
Insert = """
diff --git a/tests/functional-tests/writeback-tc.py b/tests/functional-tests/writeback-tc.py
index 74d3186..0bbd3fd 100644
--- a/tests/functional-tests/writeback-tc.py
+++ b/tests/functional-tests/writeback-tc.py
@@ -38,23 +38,26 @@ for pid in commands.getoutput("ps -ef| grep tracker-writeback | awk '{print $1}'
except OSError, e:
if not e.errno == 3 : raise e # error 3 is for noscuh process
os.system('/usr/lib/tracker/tracker-writeback -v 3 &')
+os.system(configuration.TRACKER_WRITEBACK + ' -v 3 &')
time.sleep(5)
+EXTRACT = configuration.TRACKER_EXTRACT
+
target = configuration.check_target()
if target == '2' :
- dir_path = '/home/user/MyDocs/tracker-wb-test'
+ dir_path = configuration.WB_TEST_DIR_DEVICE
"""
dir_path = '/home/user/MyDocs/.images'
"""
else :
- dir_path = '/usr/share/tracker-tests/data/tracker-wb-test'
+ dir_path = configuration.WB_TEST_DIR_HOST
print dir_path
def copy_file():
"""
- src = '/usr/share/tracker-tests/data/Images'
+ src = configuration.TEST_DATA_IMAGES
"""
- src = '/home/user/MyDocs/.images'
+ src = configuration.MYDOCS_IMAGES
dest = dir_path
print 'Copying '+src+' to '+dest
commands.getoutput('cp '+src +'/*'+ ' '+dest)
@@ -133,7 +136,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nie:description')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nie:description')
print result
value=result.split()
if (result.find('nie:description')!=-1) and (value[1]=='"testdescription"') :
@@ -186,7 +189,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nie:copyright')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nie:copyright')
print result
value=result.split()
if (result.find('nie:copyright')!=-1) and (value[1]=='"testcopyright"') :
@@ -232,7 +235,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nie:title')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nie:title')
print result
value=result.split()
if (result.find('nie:title')!=-1) and (value[1]=='"testtitle"') :
@@ -278,7 +281,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nie:contentCreated')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nie:contentCreated')
print result
value=result.split()
if (result.find('nie:contentCreated')!=-1) and (value[1]=='"testcontentCreated"') :
@@ -324,7 +327,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nie:keyword')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nie:keyword')
print result
value=result.split()
if (result.find('nie:keyword')!=-1) and (value[1]=='"testkeyword"') :
@@ -370,7 +373,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nco:contributor')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nco:contributor')
print result
value=result.split()
if (result.find('nco:contributor')!=-1) and (value[1]=='"testcontributor"') :
@@ -415,7 +418,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nco:creator')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nco:creator')
print result
value=result.split()
if (result.find('nco:creator')!=-1) and (value[1]=='"testcreator"') :
@@ -460,7 +463,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:camera')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:camera')
print result
value=result.split()
if (result.find('nmm:camera')!=-1) and (value[1]=='"test') and (value[2]=='camera"'):
@@ -505,7 +508,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:exposureTime')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:exposureTime')
print result
value=result.split()
if (result.find('nmm:exposureTime')!=-1) and (value[1]=='1.44') :
@@ -550,7 +553,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:fnumber')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:fnumber')
print result
value=result.split()
if (result.find('nmm:fnumber')!=-1) and (value[1]=='707') :
@@ -596,7 +599,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:flash')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:flash')
print result
value=result.split()
if (result.find('nmm:flash')!=-1) and (value[1]=='nmm:flash-off') :
@@ -641,7 +644,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:flash')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:flash')
print result
value=result.split()
if (result.find('nmm:flash')!=-1) and (value[1]=='nmm:flash-on') :
@@ -687,7 +690,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:focalLength')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:focalLength')
print result
value=result.split()
if (result.find('nmm:focalLength')!=-1) and (value[1]=='1.44') :
@@ -732,7 +735,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:isoSpeed')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:isoSpeed')
print result
value=result.split()
if (result.find('nmm:isoSpeed')!=-1) and (value[1]=='1.44') :
@@ -777,7 +780,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:meteringMode')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:meteringMode')
print result
value=result.split()
if (result.find('nmm:meteringMode')!=-1) and (value[1]=='nmm:metering-mode-multispot') :
@@ -822,7 +825,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep nmm:whiteBalance')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep nmm:whiteBalance')
print result
value=result.split()
if (result.find('nmm:whiteBalance')!=-1) and (value[1]=='nmm:white-balance-auto') :
@@ -867,7 +870,7 @@ class writeback(TestWriteback):
self.sparql_update (insert)
""" verify the inserted item """
- result=commands.getoutput('/usr/lib/tracker/tracker-extract ' + '-f' +' ' + uri +' | grep mlo:location')
+ result=commands.getoutput(EXTRACT + ' -f' +' ' + uri +' | grep mlo:location')
print result
value=result.split()
if (result.find('mlo:location')!=-1) and (value[1]=='"clevland"') :
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]