|
@@ -1,5 +1,6 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
2
|
|
|
3
|
+from datetime import datetime
|
3
|
4
|
from nose.tools import eq_
|
4
|
5
|
from nose.tools import ok_
|
5
|
6
|
from nose.tools import raises
|
|
@@ -7,6 +8,7 @@ from nose.tools import raises
|
7
|
8
|
from sqlalchemy.orm.exc import NoResultFound
|
8
|
9
|
|
9
|
10
|
import transaction
|
|
11
|
+import tg
|
10
|
12
|
|
11
|
13
|
from tracim.model import DBSession
|
12
|
14
|
|
|
@@ -73,6 +75,8 @@ class TestSerializers(TestStandard):
|
73
|
75
|
eq_(3, len(res.keys()))
|
74
|
76
|
|
75
|
77
|
def test_serialize_Content_DEFAULT(self):
|
|
78
|
+ self.app.get('/_test_vars') # Allow to create fake context
|
|
79
|
+
|
76
|
80
|
obj = Content()
|
77
|
81
|
obj.content_id = 132
|
78
|
82
|
obj.label = 'Some label'
|
|
@@ -92,61 +96,50 @@ class TestSerializers(TestStandard):
|
92
|
96
|
eq_(None, res.workspace, res)
|
93
|
97
|
eq_(4, len(res.keys()), res)
|
94
|
98
|
|
|
99
|
+ def test_serialize_Content_comment_THREAD(self):
|
|
100
|
+ wor = Workspace()
|
|
101
|
+ wor.workspace_id = 4
|
95
|
102
|
|
|
103
|
+ fol = Content()
|
|
104
|
+ fol.type = ContentType.Folder
|
|
105
|
+ fol.content_id = 72
|
|
106
|
+ fol.workspace = wor
|
96
|
107
|
|
97
|
|
- # def test_serialize_Content_comment_THREAD(self):
|
98
|
|
- #
|
99
|
|
- # wor = Workspace()
|
100
|
|
- # wor.workspace_id = 4
|
101
|
|
- #
|
102
|
|
- # fol = Content()
|
103
|
|
- # fol.type = ContentType.Folder
|
104
|
|
- # fol.content_id = 72
|
105
|
|
- # fol.workspace = wor
|
106
|
|
- #
|
107
|
|
- # par = Content()
|
108
|
|
- # par.type = ContentType.Thread
|
109
|
|
- # par.content_id = 37
|
110
|
|
- # par.parent = fol
|
111
|
|
- # par.workspace = wor
|
112
|
|
- #
|
113
|
|
- # obj = Content()
|
114
|
|
- # obj.type = ContentType.Comment
|
115
|
|
- # obj.content_id = 132
|
116
|
|
- # obj.label = 'some label'
|
117
|
|
- # obj.description = 'Some Description'
|
118
|
|
- # obj.parent = par
|
119
|
|
- #
|
120
|
|
- # res = Context(CTX.THREAD).toDict(obj)
|
121
|
|
- # eq_(res.__class__, DictLikeClass, res)
|
122
|
|
- #
|
123
|
|
- # ok_('label' in res.keys())
|
124
|
|
- # eq_(obj.label, res.label, res)
|
125
|
|
- #
|
126
|
|
- # ok_('content' in res.keys())
|
127
|
|
- # eq_(obj.description, res.content, res)
|
128
|
|
- #
|
129
|
|
- # ok_('created' in res.keys())
|
130
|
|
- #
|
131
|
|
- # ok_('icon' in res.keys())
|
132
|
|
- # eq_(ContentType.icon(obj.type), res.icon, res)
|
133
|
|
- #
|
134
|
|
- # ok_('id' in res.folder.keys())
|
135
|
|
- # eq_(obj.content_id, res.id, res)
|
136
|
|
- #
|
137
|
|
- # ok_('owner' in res.folder.keys())
|
138
|
|
- # eq_(None, res.owner, res) # TODO - test with a owner value
|
139
|
|
- #
|
140
|
|
- # ok_('type' in res.folder.keys())
|
141
|
|
- # eq_(obj.type, res.type, res)
|
142
|
|
- #
|
143
|
|
- # ok_('urls' in res.folder.keys())
|
144
|
|
- # ok_('delete' in res.urls.keys())
|
145
|
|
- #
|
146
|
|
- # eq_(8, len(res.keys()), res)
|
|
108
|
+ par = Content()
|
|
109
|
+ par.type = ContentType.Thread
|
|
110
|
+ par.content_id = 37
|
|
111
|
+ par.parent = fol
|
|
112
|
+ par.workspace = wor
|
|
113
|
+ par.created = datetime.now()
|
147
|
114
|
|
148
|
|
- def test_serializer_get_converter_return_CTX_DEFAULT(self):
|
|
115
|
+ obj = Content()
|
|
116
|
+ obj.type = ContentType.Comment
|
|
117
|
+ obj.content_id = 132
|
|
118
|
+ obj.label = 'some label'
|
|
119
|
+ obj.description = 'Some Description'
|
|
120
|
+ obj.parent = par
|
|
121
|
+ obj.created = datetime.now()
|
|
122
|
+
|
|
123
|
+ print('LANGUAGES #2 ARE', tg.i18n.get_lang())
|
|
124
|
+ res = Context(CTX.THREAD).toDict(obj)
|
|
125
|
+ eq_(res.__class__, DictLikeClass, res)
|
|
126
|
+
|
|
127
|
+ ok_('label' in res.keys())
|
|
128
|
+ eq_(obj.label, res.label, res)
|
|
129
|
+
|
|
130
|
+ ok_('content' in res.keys())
|
|
131
|
+ eq_(obj.description, res.content, res)
|
149
|
132
|
|
|
133
|
+ ok_('created' in res.keys())
|
|
134
|
+
|
|
135
|
+ ok_('icon' in res.keys())
|
|
136
|
+ eq_(ContentType.get_icon(obj.type), res.icon, res)
|
|
137
|
+
|
|
138
|
+ ok_('delete' in res.urls.keys())
|
|
139
|
+
|
|
140
|
+ eq_(10, len(res.keys()), len(res.keys()))
|
|
141
|
+
|
|
142
|
+ def test_serializer_get_converter_return_CTX_DEFAULT(self):
|
150
|
143
|
class A(object):
|
151
|
144
|
pass
|
152
|
145
|
|
|
@@ -168,8 +161,9 @@ class TestSerializers(TestStandard):
|
168
|
161
|
|
169
|
162
|
converter = Context.get_converter(CTX.FILE, A)
|
170
|
163
|
|
171
|
|
- def test_serializer_toDict_int_str_and_LazyString(self):
|
172
|
164
|
|
|
165
|
+
|
|
166
|
+ def test_serializer_toDict_int_str_and_LazyString(self):
|
173
|
167
|
s = Context(CTX.DEFAULT).toDict(5)
|
174
|
168
|
ok_(isinstance(s, int))
|
175
|
169
|
eq_(5, s)
|
|
@@ -184,7 +178,6 @@ class TestSerializers(TestStandard):
|
184
|
178
|
eq_(lazystr, s3)
|
185
|
179
|
|
186
|
180
|
def test_serializer_toDict_for_list_of_objects(self):
|
187
|
|
-
|
188
|
181
|
class A(object):
|
189
|
182
|
def __init__(self, name):
|
190
|
183
|
self.name = name
|
|
@@ -226,8 +219,6 @@ class TestSerializers(TestStandard):
|
226
|
219
|
|
227
|
220
|
|
228
|
221
|
def test_serializer_content__menui_api_context__children(self):
|
229
|
|
- self.app.get('/_test_vars') # Allow to create fake context
|
230
|
|
-
|
231
|
222
|
folder_without_child = Content()
|
232
|
223
|
folder_without_child.type = ContentType.Folder
|
233
|
224
|
res = Context(CTX.MENU_API).toDict(folder_without_child)
|