# Copyright (C) 2009, Tutorius.org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import unittest from sugar.tutorius.store import * g_tutorial_id = '4075' g_other_id = '47efc6ee-b2a3-11de-8cfc-001f5bf747dc' class StoreProxyTest(unittest.TestCase): def setUp(self): self.store = StoreProxy() def tearDown(self): pass def test_get_categories(self): categories = self.store.get_categories() assert isinstance(categories, list), "categories should be a list" def test_get_tutorials(self): self.store.get_tutorials() def test_get_latest_version(self): version_dict = self.store.get_latest_version([]) assert isinstance(version_dict, dict) def test_download_tutorial(self): tutorial = self.store.download_tutorial(g_tutorial_id) assert tutorial is not None def test_login(self): assert self.store.login("benoit.tremblay1@gmail.com", "tutorius12") def test_register_new_user(self): user_info = { 'nickname' : "Albert2", 'password' : "tutorius12", 'email' : 'albertthetester2@mozambique.org' } assert self.store.register_new_user(user_info) class StoreProxyLoginTest(unittest.TestCase): def setUp(self): self.store = StoreProxy() self.store.login("benoit.tremblay1@gmail.com", "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() assert session_id is not None def test_rate(self): assert self.store.rate(5, g_tutorial_id) def test_publish(self): # TODO : We need to send in a real tutorial loaded from # the Vault tutorial_info = { 'name': 'newtut', 'summary': 'This is a tutorial', 'filename': 'test.xml', 'homepage': 'http://google.com', 'version': '1', 'cat1': '17', 'cat2': '18', 'cat3': '' } 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) def test_update_published_tutorial(self): # TODO : Run these tests with files from the Vault #self.store.publish([g_tutorial_id, 'Fake tutorial']) tutorial_info = { 'name': 'newtut', 'summary': 'This is a tutorial', 'filename': 'test.xml', 'homepage': 'http://google.com', 'version': '1', 'cat1': '17', 'cat2': '18', 'cat3': '' } assert self.store.update_published_tutorial(g_tutorial_id, 'This is an updated tutorial', tutorial_info)