From 86511b28a7949a548213fb7d1cbbb6126208965e Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 02 Nov 2009 19:23:15 +0000 Subject: final version of the StoreProxy and its tests --- (limited to 'tests/storetests.py') diff --git a/tests/storetests.py b/tests/storetests.py index 73ac2f7..97aa5e3 100644 --- a/tests/storetests.py +++ b/tests/storetests.py @@ -16,14 +16,15 @@ import unittest +import random from sugar.tutorius.store import * -g_tutorial_id = '4075' -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 @@ -42,7 +43,7 @@ class StoreProxyTest(unittest.TestCase): assert isinstance(version_dict, dict) 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 @@ -50,10 +51,11 @@ class StoreProxyTest(unittest.TestCase): assert self.store.login("benoit.tremblay1@gmail.com", "tutorius12") def test_register_new_user(self): + random_num = str(random.randint(0, 999999999)) user_info = { - 'nickname' : "Albert2", + 'nickname' : "Albert%s" % (random_num), 'password' : "tutorius12", - 'email' : 'albertthetester2@mozambique.org' + 'email' : 'albertthetester%s@mozambique.org' % (random_num) } assert self.store.register_new_user(user_info) @@ -61,17 +63,14 @@ class StoreProxyTest(unittest.TestCase): class StoreProxyLoginTest(unittest.TestCase): def setUp(self): - self.store = StoreProxy() - self.store.login("benoit.tremblay1@gmail.com", "tutorius12") + self.store = StoreProxy("http://bobthebuilder.mine.nu/tutorius/en-US/tutorius") + self.store.login("nobody@mozilla.org", "tutorius12") def tearDown(self): session_id = self.store.get_session_id() if session_id is not None: self.store.close_session() - - def test_close_session(self): - assert self.store.close_session() def test_get_session_id(self): session_id = self.store.get_session_id() @@ -97,11 +96,13 @@ class StoreProxyLoginTest(unittest.TestCase): assert self.store.publish('This should be a real tutorial...', tutorial_info) 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) def test_update_published_tutorial(self): # TODO : Run these tests with files from the Vault @@ -109,10 +110,10 @@ class StoreProxyLoginTest(unittest.TestCase): tutorial_info = { 'name': 'newtut', - 'summary': 'This is a tutorial', + 'summary': 'This is an updated tutorial', 'filename': 'test.xml', 'homepage': 'http://google.com', - 'version': '1', + 'version': '2', 'cat1': '17', 'cat2': '18', 'cat3': '' @@ -120,3 +121,6 @@ class StoreProxyLoginTest(unittest.TestCase): 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() + -- cgit v0.9.1