diff options
author | JCTutorius <charlie@tutorius-dev.(none)> | 2009-10-29 18:19:34 (GMT) |
---|---|---|
committer | JCTutorius <charlie@tutorius-dev.(none)> | 2009-10-29 18:19:34 (GMT) |
commit | 02c264b69b406393c1ea40d4c26ee29e2b522fa3 (patch) | |
tree | 3cb31ddbdc8ee7ba11b331cb439b8b3dc0d2cf9a | |
parent | c16f29574cd9f8de15507e0d50139eeabfc2d266 (diff) |
Added ressources vault function and tests in vaulttests.py
-rw-r--r-- | tests/vaulttests.py | 23 | ||||
-rw-r--r-- | tutorius/vault.py | 7 |
2 files changed, 23 insertions, 7 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py index b56def2..d6787ef 100644 --- a/tests/vaulttests.py +++ b/tests/vaulttests.py @@ -278,19 +278,18 @@ class VaultInterfaceTest(unittest.TestCase): # (so we can specifiy that we want only the metadata for this particular tutorial - def test_add_ressource(self): + 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. + 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 - vault = Vault() tutorial = Tutorial('test', self.fsm) - vault.saveTutorial(tutorial, self.test_metadata_dict) + Vault.saveTutorial(tutorial, self.test_metadata_dict) bundler = TutorialBundler(self.save_test_guid) tuto_path = bundler.get_tutorial_path(self.save_test_guid) @@ -301,6 +300,22 @@ class VaultInterfaceTest(unittest.TestCase): # 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): diff --git a/tutorius/vault.py b/tutorius/vault.py index 47665fc..e4caeb1 100644 --- a/tutorius/vault.py +++ b/tutorius/vault.py @@ -364,11 +364,12 @@ class Vault(object): bundler = TutorialBundler(tutorial_guid) tutorial_path = bundler.get_tutorial_path(tutorial_guid) # Check if the ressource file exists - file_path = os.path.join(tutorial_path, ressource_id) + file_path = os.path.join(tutorial_path, RESSOURCES_FOLDER, ressource_id) if os.path.isfile(file_path): # Delete the ressource - os.delete(os.path.join(tutorial_path, ressource_id)) - + os.remove(file_path) + else: + print('File not found, no delete took place') @staticmethod def get_ressource_path(tutorial_guid, ressource_id): |