Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/vaulttests.py
diff options
context:
space:
mode:
authorJCTutorius <charlie@tutorius-dev.(none)>2009-11-19 19:19:17 (GMT)
committer JCTutorius <charlie@tutorius-dev.(none)>2009-11-19 19:19:17 (GMT)
commit40bbbd091ae330d572408613f3efdc82b3cb6a4e (patch)
treed787ed89fb7118d278a01be3a31719cd95ade059 /tests/vaulttests.py
parentd9d397fcc0139ccf940e268972069dad5730b8e8 (diff)
Implemented the query() vault function with search parameters.
Diffstat (limited to 'tests/vaulttests.py')
-rw-r--r--tests/vaulttests.py66
1 files changed, 56 insertions, 10 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py
index e8e732e..729d36d 100644
--- a/tests/vaulttests.py
+++ b/tests/vaulttests.py
@@ -92,7 +92,7 @@ class VaultInterfaceTest(unittest.TestCase):
ini_file2.write('guid=' + str(self.test_guid2) + '\n')
ini_file2.write('name=TestTutorial2\n')
ini_file2.write('version=2\n')
- ini_file2.write('description=This is a test tutorial 2\n')
+ ini_file2.write('description=This is a test tutorial 2. FOR_TEST\n')
ini_file2.write('rating=4\n')
ini_file2.write('category=Test2\n')
ini_file2.write('publish_state=false\n')
@@ -125,7 +125,7 @@ class VaultInterfaceTest(unittest.TestCase):
self.test_metadata_dict['publish_state'] = 'false'
activities_dict = {}
activities_dict['org.laptop.tutoriusactivity'] = '1'
- activities_dict['org.laptop,writus'] = '1'
+ activities_dict['org.laptop.writus'] = '1'
self.test_metadata_dict['activities'] = activities_dict
@@ -142,7 +142,7 @@ class VaultInterfaceTest(unittest.TestCase):
shutil.rmtree(os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp'))
os.makedirs(test_path)
- # Creat a dummy tutorial .xml file
+ # Create a dummy tutorial .xml file
serializer = XMLSerializer()
with file(os.path.join(test_path, 'tutorial.xml'), 'w') as fsmfile:
@@ -159,7 +159,7 @@ class VaultInterfaceTest(unittest.TestCase):
zout = zipfile.ZipFile(os.path.join(test_path, zfilename), "w")
for fname in archive_list:
fname_splitted = fname.rsplit('/')
- file_only_name = fname_splitted[fname_splitted.__len__() - 1]
+ file_only_name = fname_splitted[-1]
zout.write(fname, file_only_name)
zout.close()
@@ -186,12 +186,10 @@ class VaultInterfaceTest(unittest.TestCase):
correspond to the specified parameters.
"""
- # Note : Temporary only test query that return ALL tutorials in the vault.
- # TODO : Test with varying parameters
-
+ # Test the return of all the tutorials
tutorial_list = Vault.query()
- if tutorial_list.__len__() < 2:
+ if len(tutorial_list) < 2:
assert False, 'Error, list doesnt have enough tutorial in it : ' + str(tutorial_list.__len__()) + ' element'
for tuto_dictionnary in tutorial_list:
@@ -208,7 +206,7 @@ class VaultInterfaceTest(unittest.TestCase):
elif tuto_dictionnary['name'] == 'TestTutorial2':
related = tuto_dictionnary['activities']
assert tuto_dictionnary['version'] == '2'
- assert tuto_dictionnary['description'] == 'This is a test tutorial 2'
+ assert tuto_dictionnary['description'] == 'This is a test tutorial 2. FOR_TEST'
assert tuto_dictionnary['rating'] == '4'
assert tuto_dictionnary['category'] == 'Test2'
assert tuto_dictionnary['publish_state'] == 'false'
@@ -218,7 +216,55 @@ class VaultInterfaceTest(unittest.TestCase):
else:
assert False, 'list is empty or name property is wrong'
-
+
+ # Test the return of just a given tutorial with a given keyword present in one
+ # or more of is metadata fields.
+ tutorial_list = Vault.query(keyword=['FOR_TEST'])
+
+ # Should return only tutorial with metadata like tutorial # 2
+ if len(tutorial_list) == 0:
+ assert False, 'Error on keyword, at least 1 tutorial should has been returned. '
+ related = tutorial_list[0]['activities']
+ assert tutorial_list[0]['version'] == '2'
+ assert tutorial_list[0]['description'] == 'This is a test tutorial 2. FOR_TEST'
+ assert tutorial_list[0]['rating'] == '4'
+ assert tutorial_list[0]['category'] == 'Test2'
+ assert tutorial_list[0]['publish_state'] == 'false'
+ assert related.has_key('org.laptop.tutoriusactivity')
+ assert related.has_key('org.laptop.writus')
+ assert related.has_key('org.laptop.testus')
+
+ # Test the return of just a given tutorial with a given related activity in is metadata
+ tutorial_list = Vault.query(relatedActivityNames=['org.laptop.testus'])
+
+ # Should return only tutorials like tutorial # 2
+ if len(tutorial_list) == 0:
+ assert False, 'Error on related activity, at least 1 tutorial should has been returned. '
+ related = tutorial_list[0]['activities']
+ assert tutorial_list[0]['version'] == '2'
+ assert tutorial_list[0]['description'] == 'This is a test tutorial 2. FOR_TEST'
+ assert tutorial_list[0]['rating'] == '4'
+ assert tutorial_list[0]['category'] == 'Test2'
+ assert tutorial_list[0]['publish_state'] == 'false'
+ assert related.has_key('org.laptop.tutoriusactivity')
+ assert related.has_key('org.laptop.writus')
+ assert related.has_key('org.laptop.testus')
+
+ # Test the return of just a given tutorial with a given category in is metadata
+ tutorial_list = Vault.query(category=['test'])
+
+ # Should return only tutorials like tutorial # 1
+ if len(tutorial_list) == 0:
+ assert False, 'Error on category, at least 1 tutorial should has been returned. '
+ related = tutorial_list[0]['activities']
+ assert tutorial_list[0]['version'] == '1'
+ assert tutorial_list[0]['description'] == 'This is a test tutorial 1'
+ assert tutorial_list[0]['rating'] == '3.5'
+ assert tutorial_list[0]['category'] == 'Test'
+ assert tutorial_list[0]['publish_state'] == 'false'
+ assert related.has_key('org.laptop.tutoriusactivity')
+ assert related.has_key('org.laptop.writus')
+
def test_loadTutorial(self):
"""