Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/vaulttests.py79
1 files changed, 76 insertions, 3 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py
index c6bd852..5fdb7f9 100644
--- a/tests/vaulttests.py
+++ b/tests/vaulttests.py
@@ -187,9 +187,7 @@ class VaultInterfaceTest(unittest.TestCase):
# Note : Temporary only test query that return ALL tutorials in the vault.
# TODO : Test with varying parameters
- vault = Vault()
-
- tutorial_list = vault.query()
+ tutorial_list = Vault.query()
if tutorial_list.__len__() < 2:
assert False, 'Error, list doesnt have enough tutorial in it : ' + str(tutorial_list.__len__()) + ' element'
@@ -259,6 +257,81 @@ class VaultInterfaceTest(unittest.TestCase):
# TODO : Compare the initial and reloaded metadata when vault.Query() will accept specifc argument
# (so we can specifiy that we want only the metadata for this particular tutorial
+ def test_update_metadata(self):
+ """
+ This test verify that the vault interface funciton update_metadata succesfully update a tutorial metadata.
+ """
+ # Create and save a tutorial
+ tutorial = Tutorial('test')
+ Vault.saveTutorial(tutorial, self.test_metadata_dict)
+
+ bundler = TutorialBundler(self.save_test_guid)
+
+ # Create a metadata dictionnary different than the initial one
+ test_new_metadata_dict = {}
+ test_new_metadata_dict['name'] = 'TestTutorial_modified'
+ test_new_metadata_dict['guid'] = str(self.save_test_guid)
+ test_new_metadata_dict['version'] = '3'
+ test_new_metadata_dict['description'] = 'This is a test tutorial modified'
+ test_new_metadata_dict['rating'] = '4.5'
+ test_new_metadata_dict['category'] = 'Test_modified'
+ test_new_metadata_dict['publish_state'] = 'true'
+ new_activities_dict = {}
+ new_activities_dict['org.laptop.tutoriusactivity'] = '2'
+ new_activities_dict['org.laptop.writus'] = '2'
+ test_new_metadata_dict['activities'] = new_activities_dict
+
+ # Test update_metadata
+ Vault.update_metadata(self.save_test_guid, test_new_metadata_dict)
+
+ # Get the metadata back
+ tutorial_list = Vault.query()
+
+ new_metadata_found = False
+
+ # Test that the metadata in the tutorial is indeed the new one
+ for tuto_dictionnary in tutorial_list:
+ if tuto_dictionnary['name'] == 'TestTutorial_modified':
+ # Flag that indicate that the modified metadata has been found
+ new_metadata_found = True
+ related = tuto_dictionnary['activities']
+ assert tuto_dictionnary['version'] == '3'
+ assert tuto_dictionnary['description'] == 'This is a test tutorial modified'
+ assert tuto_dictionnary['rating'] == '4.5'
+ assert tuto_dictionnary['category'] == 'Test_modified'
+ assert tuto_dictionnary['publish_state'] == 'true'
+ assert related.has_key('org.laptop.tutoriusactivity')
+ assert related.has_key('org.laptop.writus')
+
+ # If false, new metadata hasn't been found in the vault
+ assert new_metadata_found == True, 'Modified metadata not found in the vault'
+
+
+ def test_get_tutorial_archive(self):
+ """
+ This test verify that the vault interface function get_tutorial_archive zip a tutorial and
+ return the zipped archive object succesfully.
+ """
+ # Create and save a tutorial
+ tutorial = Tutorial('test')
+ Vault.saveTutorial(tutorial, self.test_metadata_dict)
+
+ bundler = TutorialBundler(self.save_test_guid)
+
+ # Test get_tutorial_archive()
+ archive_object = Vault.get_tutorial_archive(self.save_test_guid)
+
+ # Write the archive data as a new file
+ zip_path = str(self.save_test_guid) + '_test_.zip'
+ file = open(zip_path, 'wt')
+ file.write(archive_object)
+ file.close()
+
+ # Test if new zip is valid
+ assert zipfile.is_zipfile(zip_path)
+ # Remove test file
+ os.remove(zip_path)
+
def test_add_delete_get_path_resource(self):
"""