Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJCTutorius <charlie@tutorius-dev.(none)>2009-11-05 20:13:55 (GMT)
committer JCTutorius <charlie@tutorius-dev.(none)>2009-11-05 20:13:55 (GMT)
commit6f15a67eab8c88ae43def2acd2cfaaa943c7537d (patch)
tree129454efe0a2a3e6dc9a44ccfcc2197193c31f0c
parent80c7d20f83d15890a31b5e0a584dfcb24fb3f2a6 (diff)
Added code review modifications to Valut ressource managing.
-rw-r--r--tests/vaulttests.py19
-rw-r--r--tutorius/vault.py5
2 files changed, 15 insertions, 9 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py
index d085faf..c6bd852 100644
--- a/tests/vaulttests.py
+++ b/tests/vaulttests.py
@@ -266,18 +266,26 @@ class VaultInterfaceTest(unittest.TestCase):
and return the new resource id. It also test the deletion of the resource.
"""
# Path of an image file in the test folder
- image_path = os.path.join(os.getcwd(), 'tests', 'resources', 'icon.svg')
- assert os.path.isfile(image_path), 'cannot find the test image file'
-
+ test_path = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp')
+ if os.path.isdir(test_path) == True:
+ shutil.rmtree(os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp'))
+ os.makedirs(test_path)
+ file_path = os.path.join(test_path, 'test_resource.svg')
+ resource_file = open(file_path, 'wt')
+ resource_file.write('test')
+ resource_file.close()
+ #image_path = os.path.join(os.getcwd(), 'tests', 'resources', 'icon.svg')
+ #assert os.path.isfile(image_path), 'cannot find the test image file'
+
# Create and save a tutorial
- tutorial = Tutorial('test', self.fsm)
+ tutorial = Tutorial('test')
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 resource to the tutorial
- resource_id = Vault.add_resource(self.save_test_guid, image_path)
+ resource_id = Vault.add_resource(self.save_test_guid, file_path)
# Check that the image file is now in the vault
assert os.path.isfile(os.path.join(tuto_path, 'resources', resource_id)), 'image file not found in vault'
@@ -288,7 +296,6 @@ class VaultInterfaceTest(unittest.TestCase):
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 resource
Vault.delete_resource(self.save_test_guid, resource_id)
diff --git a/tutorius/vault.py b/tutorius/vault.py
index 728cf64..7ec0a23 100644
--- a/tutorius/vault.py
+++ b/tutorius/vault.py
@@ -353,7 +353,7 @@ class Vault(object):
@param file_path the file path of the resource to add
@returns the resource_id of the resource
"""
-
+ assert os.path.isfile(file_path)
# Get the tutorial path
bundler = TutorialBundler(tutorial_guid)
tutorial_path = bundler.get_tutorial_path(tutorial_guid)
@@ -370,7 +370,6 @@ class Vault(object):
# Copy the resource file in the vault
if os.path.isdir(os.path.join(tutorial_path, RESOURCES_FOLDER)) == False:
os.makedirs(os.path.join(tutorial_path, RESOURCES_FOLDER))
- assert os.path.isfile(file_path)
shutil.copyfile(file_path, new_file_path)
return file_name_appended
@@ -392,7 +391,7 @@ class Vault(object):
# Delete the resource
os.remove(file_path)
else:
- print('File not found, no delete took place')
+ logging.info('File not found, no delete took place')
@staticmethod
def get_resource_path(tutorial_guid, resource_id):