From 64b9250ca5aed2edadc331b1bc7f31e7db294185 Mon Sep 17 00:00:00 2001 From: JCTutorius Date: Fri, 06 Nov 2009 00:34:37 +0000 Subject: Finished code and testing of update_metadata and get_tutorial_archhive Vault functions. --- (limited to 'tests') diff --git a/tests/vaulttests.py b/tests/vaulttests.py index 9c51f85..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' @@ -263,7 +261,50 @@ class VaultInterfaceTest(unittest.TestCase): """ This test verify that the vault interface funciton update_metadata succesfully update a tutorial metadata. """ - pass + # 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): -- cgit v0.9.1