diff options
Diffstat (limited to 'tests/storetests.py')
-rw-r--r-- | tests/storetests.py | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/tests/storetests.py b/tests/storetests.py index 0d1d9af..0c36973 100644 --- a/tests/storetests.py +++ b/tests/storetests.py @@ -15,16 +15,18 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import unittest +import uuid from tests.utils import skip, catch_unimplemented +import random from sugar.tutorius.store import * -g_tutorial_id = '114db454-b2a1-11de-8cfc-001f5bf747dc' -g_other_id = '47efc6ee-b2a3-11de-8cfc-001f5bf747dc' +g_tutorial_id = '4079' +g_other_id = '4080' class StoreProxyTest(unittest.TestCase): def setUp(self): - self.store = StoreProxy() + self.store = StoreProxy("http://bobthebuilder.mine.nu/tutorius/en-US/tutorius") def tearDown(self): pass @@ -39,13 +41,6 @@ class StoreProxyTest(unittest.TestCase): def test_get_tutorials(self): self.store.get_tutorials() - @catch_unimplemented - def test_get_tutorial_collection(self): - collection_list = self.store.get_tutorial_collection('top5_rating') - - assert isinstance(collection_list, list), "get_tutorial_collection should return a list" - - @catch_unimplemented def test_get_latest_version(self): version_dict = self.store.get_latest_version([]) @@ -53,21 +48,21 @@ class StoreProxyTest(unittest.TestCase): @catch_unimplemented def test_download_tutorial(self): - tutorial = self.store.download_tutorial(g_tutorial_id) + tutorial = self.store.download_tutorial(g_other_id) assert tutorial is not None @catch_unimplemented def test_login(self): - assert self.store.login("unknown_user", "random_password") + assert self.store.login("benoit.tremblay1@gmail.com", "tutorius12") @catch_unimplemented def test_register_new_user(self): + random_num = str(random.randint(0, 999999999)) user_info = { - 'name' : "Albert", - 'last_name' : "The Tester", - 'location' : 'Mozambique', - 'email' : 'albertthetester@mozambique.org' + 'nickname' : "Albert%s" % (random_num), + 'password' : "tutorius12", + 'email' : 'albertthetester%s@mozambique.org' % (random_num) } assert self.store.register_new_user(user_info) @@ -76,8 +71,8 @@ class StoreProxyTest(unittest.TestCase): class StoreProxyLoginTest(unittest.TestCase): @catch_unimplemented def setUp(self): - self.store = StoreProxy() - self.store.login("unknown_user", "random_password") + self.store = StoreProxy("http://bobthebuilder.mine.nu/tutorius/en-US/tutorius") + self.store.login("nobody@mozilla.org", "tutorius12") @catch_unimplemented def tearDown(self): @@ -85,10 +80,6 @@ class StoreProxyLoginTest(unittest.TestCase): if session_id is not None: self.store.close_session() - - @catch_unimplemented - def test_close_session(self): - assert self.store.close_session() @catch_unimplemented def test_get_session_id(self): @@ -104,20 +95,47 @@ class StoreProxyLoginTest(unittest.TestCase): def test_publish(self): # TODO : We need to send in a real tutorial loaded from # the Vault - assert self.store.publish(['This should be a real tutorial...']) + tutorial_info = { + 'name': 'newtut', + 'summary': 'This is a tutorial', + 'filename': 'test.xml', + 'guid': str(uuid.uuid1()), + 'homepage': 'http://google.com', + 'version': '1', + 'cat1': '17', + 'cat2': '18', + 'cat3': '' + } + assert self.store.publish('This should be a real tutorial...', tutorial_info) != -1 @catch_unimplemented def test_unpublish(self): - # TODO : We need to send in a real tutorial loaded from - # the Vault - self.store.publish([g_tutorial_id, 'Fake tutorial']) - assert self.store.unpublish(g_tutorial_id) + + # Republish the tutorial + self.store.publish(None, None, g_tutorial_id) + + def test_republish(self): + assert self.store.publish(None, None, g_tutorial_id) @catch_unimplemented def test_update_published_tutorial(self): # TODO : Run these tests with files from the Vault - self.store.publish([g_tutorial_id, 'Fake tutorial']) + #self.store.publish([g_tutorial_id, 'Fake tutorial']) + + tutorial_info = { + 'name': 'newtut', + 'summary': 'This is an updated tutorial', + 'filename': 'test.xml', + 'homepage': 'http://google.com', + 'version': '2', + 'cat1': '17', + 'cat2': '18', + 'cat3': '' + } - assert self.store.update_published_tutorial(g_tutorial_id, [g_tutorial_id, 'This is an updated tutorial']) + assert self.store.update_published_tutorial(g_tutorial_id, 'This is an updated tutorial', tutorial_info) + + def test_close_session(self): + assert self.store.close_session() |