From 134d1333acc68ac2ccd3b0459df1be948500f1a7 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 06 Nov 2009 03:30:36 +0000 Subject: Merge branch 'lp458452' of ../mainline Conflicts: tests/vaulttests.py tutorius/vault.py --- (limited to 'tests/vaulttests.py') diff --git a/tests/vaulttests.py b/tests/vaulttests.py index 6d69ca9..48869a7 100644 --- a/tests/vaulttests.py +++ b/tests/vaulttests.py @@ -259,6 +259,47 @@ 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_add_delete_get_path_ressource(self): + """ + This test verify that the vault interface function add_ressource succesfully add ressource in the vault + and return the new ressource id. It also test the deletion of the ressource. + """ + # Path of an image file in the test folder + image_path = os.path.join(os.getcwd(), 'tests', 'ressources', 'icon.svg') + assert os.path.isfile(image_path), 'cannot find the test image file' + + # Create and save a tutorial + tutorial = Tutorial('test', self.fsm) + Vault.saveTutorial(tutorial, self.test_metadata_dict) + + bundler = TutorialBundler(self.save_test_guid) + tuto_path = bundler.get_tutorial_path(self.save_test_guid) + + # add the ressource to the tutorial + ressource_id = Vault.add_ressource(self.save_test_guid, image_path) + + # Check that the image file is now in the vault + assert os.path.isfile(os.path.join(tuto_path, 'ressources', ressource_id)), 'image file not found in vault' + + # Check if get_ressource_path Vault interface function is working + vault_path = Vault.get_ressource_path(self.save_test_guid, ressource_id) + + assert os.path.isfile(vault_path), 'path returned is not a file' + basename, extension = os.path.splitext(vault_path) + assert extension == '.svg', 'wrong file path have been returned' + + + # Delete the ressource + Vault.delete_ressource(self.save_test_guid, ressource_id) + + # Check that the ressource is not in the vault anymore + assert os.path.isfile(os.path.join(tuto_path, 'ressources', ressource_id)) == False, 'image file found in vault when it should have been deleted.' + + + + + def tearDown(self): folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data'); for file in os.listdir(folder): @@ -450,4 +491,4 @@ class TutorialBundlerTests(unittest.TestCase): if __name__ == "__main__": - unittest.main() + unittest.main() -- cgit v0.9.1