Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/vaulttests.py
diff options
context:
space:
mode:
authormike <michael.jmontcalm@gmail.com>2009-11-06 03:30:36 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-11-06 03:30:36 (GMT)
commit134d1333acc68ac2ccd3b0459df1be948500f1a7 (patch)
treecf1bede0add5d00fda74a00e3bc6f72f4f310fcf /tests/vaulttests.py
parentc7c7f94fc5d7e9f7e4f175c06dd52628aa357e3d (diff)
parenta4bb559bee98c48a6a372a7ffc15b027e365ff6c (diff)
Merge branch 'lp458452' of ../mainline
Conflicts: tests/vaulttests.py tutorius/vault.py
Diffstat (limited to 'tests/vaulttests.py')
-rw-r--r--tests/vaulttests.py43
1 files changed, 42 insertions, 1 deletions
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()