Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/vaulttests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vaulttests.py')
-rw-r--r--tests/vaulttests.py45
1 files changed, 17 insertions, 28 deletions
diff --git a/tests/vaulttests.py b/tests/vaulttests.py
index d210af7..a9a53ab 100644
--- a/tests/vaulttests.py
+++ b/tests/vaulttests.py
@@ -30,13 +30,12 @@ import os
import shutil
import zipfile
-# from mock import Mock
from sugar.tutorius import addon
from sugar.tutorius.core import State, FiniteStateMachine, Tutorial
from sugar.tutorius.actions import *
from sugar.tutorius.filters import *
from sugar.tutorius.vault import Vault, XMLSerializer, Serializer, TutorialBundler
-# from sugar.tutorius.bundler import XMLSerializer, Serializer
+
import sugar
from uuid import uuid1
@@ -131,12 +130,15 @@ class VaultInterfaceTest(unittest.TestCase):
self.test_metadata_dict['activities'] = activities_dict
- def test_installTutorials(self):
- # create dummy tutorial
+ def test_installTutorials(self):
+
+ # TODO : Test for erronous file too (not .xml, not .ini, not .zip, etc.)
+
+ # create dummy tutorial
# create a test folder in the file
# system outside the Vault
- test_path = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'tmp', 'testdata')
+ 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)
@@ -218,7 +220,7 @@ class VaultInterfaceTest(unittest.TestCase):
assert False, 'list is empty or name property is wrong'
- def test_openTutorial(self):
+ def test_loadTutorial(self):
"""
Test the opening of a tutorial from the vault by passing it is guid and
returning the Tutorial object representation. This test verify that the
@@ -231,7 +233,7 @@ class VaultInterfaceTest(unittest.TestCase):
test = bundler.get_tutorial_path(self.tuto_guid)
# load tutorial created in the test_installTutorial function
vault = Vault()
- reloaded_tuto = vault.openTutorial(self.tuto_guid)
+ reloaded_tuto = vault.loadTutorial(self.tuto_guid)
# Compare the two FSMs
reloaded_fsm = reloaded_tuto.state_machine
@@ -256,7 +258,7 @@ class VaultInterfaceTest(unittest.TestCase):
vault.saveTutorial(tutorial, self.test_metadata_dict, None)
# Get the tutorial back
- reloaded_tuto = vault.openTutorial(self.save_test_guid)
+ reloaded_tuto = vault.loadTutorial(self.save_test_guid)
# Compare the two FSMs
reloaded_fsm = reloaded_tuto.state_machine
@@ -276,7 +278,6 @@ class VaultInterfaceTest(unittest.TestCase):
def tearDown(self):
- pass
folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data');
for file in os.listdir(folder):
file_path = os.path.join(folder, file)
@@ -501,25 +502,13 @@ class TutorialBundlerTests(unittest.TestCase):
ini_file.close()
def tearDown(self):
- pass
-## os.remove(self.ini_file)
-## os.rmdir(self.guid_path)
-##
-## folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data');
-## for file in os.listdir(folder):
-## file_path = os.path.join(folder, file)
-## shutil.rmtree(file_path)
-
-## def test_add_ressource(self):
-## bund = bundler.TutorialBundler(str(self.test_guid))
-##
-## temp_file = open("test.txt",'w')
-## temp_file.write('test')
-## temp_file.close()
-##
-## bund.add_resource("test.txt")
-##
-## assert os.path.exists(os.path.join(self.guid_path,"test.txt")), "add_ressource did not create the file"
+ os.remove(self.ini_file)
+ os.rmdir(self.guid_path)
+
+ folder = os.path.join(os.getenv("HOME"),".sugar", 'default', 'tutorius', 'data');
+ for file in os.listdir(folder):
+ file_path = os.path.join(folder, file)
+ shutil.rmtree(file_path)
if __name__ == "__main__":