1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# 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 tests.utils import skip, catch_unimplemented
from sugar.tutorius.store import *
g_tutorial_id = '114db454-b2a1-11de-8cfc-001f5bf747dc'
g_other_id = '47efc6ee-b2a3-11de-8cfc-001f5bf747dc'
class StoreProxyTest(unittest.TestCase):
def setUp(self):
self.store = StoreProxy()
def tearDown(self):
pass
@catch_unimplemented
def test_get_categories(self):
categories = self.store.get_categories()
assert isinstance(categories, list), "categories should be a list"
@catch_unimplemented
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([])
assert isinstance(version_dict, dict)
@catch_unimplemented
def test_download_tutorial(self):
tutorial = self.store.download_tutorial(g_tutorial_id)
assert tutorial is not None
@catch_unimplemented
def test_login(self):
assert self.store.login("unknown_user", "random_password")
@catch_unimplemented
def test_register_new_user(self):
user_info = {
'name' : "Albert",
'last_name' : "The Tester",
'location' : 'Mozambique',
'email' : 'albertthetester@mozambique.org'
}
assert self.store.register_new_user(user_info)
class StoreProxyLoginTest(unittest.TestCase):
@catch_unimplemented
def setUp(self):
self.store = StoreProxy()
self.store.login("unknown_user", "random_password")
@catch_unimplemented
def tearDown(self):
session_id = self.store.get_session_id()
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):
session_id = self.store.get_session_id()
assert session_id is not None
@catch_unimplemented
def test_rate(self):
assert self.store.rate(5, g_tutorial_id)
@catch_unimplemented
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...'])
@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)
@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'])
assert self.store.update_published_tutorial(g_tutorial_id, [g_tutorial_id, 'This is an updated tutorial'])
|