|
@@ -8,6 +8,8 @@ from sqlalchemy.orm.exc import NoResultFound
|
8
|
8
|
|
9
|
9
|
import transaction
|
10
|
10
|
|
|
11
|
+from tracim.model import DBSession
|
|
12
|
+
|
11
|
13
|
from tg.util import LazyString
|
12
|
14
|
from tracim.model.data import Content
|
13
|
15
|
from tracim.model.data import ContentType
|
|
@@ -206,8 +208,6 @@ class TestSerializers(TestStandard):
|
206
|
208
|
|
207
|
209
|
s2 = Context(CTX.DEFAULT).toDict(mylist, 'subitems', 'subitems_nb')
|
208
|
210
|
|
209
|
|
- print('-----------------> ---> ', s2)
|
210
|
|
- print('-----------------> ', s2.items)
|
211
|
211
|
ok_('subitems' in s2.keys(), s2)
|
212
|
212
|
|
213
|
213
|
ok_('name' in s2.subitems[0].keys())
|
|
@@ -222,6 +222,39 @@ class TestSerializers(TestStandard):
|
222
|
222
|
eq_(3, s2.subitems_nb)
|
223
|
223
|
eq_(3, len(s2.subitems))
|
224
|
224
|
|
|
225
|
+ eq_(2, len(s2))
|
225
|
226
|
|
226
|
227
|
|
227
|
|
- eq_(2, len(s2))
|
|
228
|
+ def test_serializer_content__menui_api_context__children(self):
|
|
229
|
+ self.app.get('/_test_vars') # Allow to create fake context
|
|
230
|
+
|
|
231
|
+ folder_without_child = Content()
|
|
232
|
+ folder_without_child.type = ContentType.Folder
|
|
233
|
+ res = Context(CTX.MENU_API).toDict(folder_without_child)
|
|
234
|
+ eq_(False, res['children'])
|
|
235
|
+
|
|
236
|
+ folder_with_child = Content()
|
|
237
|
+ folder_with_child.type = ContentType.Folder
|
|
238
|
+ folder_without_child.parent = folder_with_child
|
|
239
|
+ DBSession.add(folder_with_child)
|
|
240
|
+ DBSession.add(folder_without_child)
|
|
241
|
+ DBSession.flush()
|
|
242
|
+
|
|
243
|
+ res = Context(CTX.MENU_API).toDict(folder_with_child)
|
|
244
|
+ eq_(True, res['children'])
|
|
245
|
+
|
|
246
|
+ for curtype in ContentType.all():
|
|
247
|
+ if curtype not in (ContentType.Folder, ContentType.Comment):
|
|
248
|
+ item = Content()
|
|
249
|
+ item.type = curtype
|
|
250
|
+
|
|
251
|
+ fake_child = Content()
|
|
252
|
+ fake_child.type = curtype
|
|
253
|
+ fake_child.parent = item
|
|
254
|
+
|
|
255
|
+ DBSession.add(item)
|
|
256
|
+ DBSession.add(fake_child)
|
|
257
|
+ DBSession.flush()
|
|
258
|
+
|
|
259
|
+ res = Context(CTX.MENU_API).toDict(item)
|
|
260
|
+ eq_(False, res['children'])
|