|
@@ -209,7 +209,7 @@ class TestContentApi(DefaultTest):
|
209
|
209
|
do_save=False
|
210
|
210
|
)
|
211
|
211
|
allowed_content_dict = {CONTENT_TYPES.Folder.slug: True, CONTENT_TYPES.File.slug: False} # nopep8
|
212
|
|
- api.set_allowed_content(
|
|
212
|
+ api._set_allowed_content(
|
213
|
213
|
folder,
|
214
|
214
|
allowed_content_dict=allowed_content_dict
|
215
|
215
|
)
|
|
@@ -275,7 +275,136 @@ class TestContentApi(DefaultTest):
|
275
|
275
|
parent=None,
|
276
|
276
|
label='lapin',
|
277
|
277
|
do_save=True
|
278
|
|
- )
|
|
278
|
+ )
|
|
279
|
+
|
|
280
|
+ def test_unit__set_allowed_content__ok__private_method(self):
|
|
281
|
+ uapi = UserApi(
|
|
282
|
+ session=self.session,
|
|
283
|
+ config=self.app_config,
|
|
284
|
+ current_user=None,
|
|
285
|
+ )
|
|
286
|
+ group_api = GroupApi(
|
|
287
|
+ current_user=None,
|
|
288
|
+ session=self.session,
|
|
289
|
+ config=self.app_config,
|
|
290
|
+ )
|
|
291
|
+ groups = [group_api.get_one(Group.TIM_USER),
|
|
292
|
+ group_api.get_one(Group.TIM_MANAGER),
|
|
293
|
+ group_api.get_one(Group.TIM_ADMIN)]
|
|
294
|
+
|
|
295
|
+ user = uapi.create_minimal_user(email='this.is@user',
|
|
296
|
+ groups=groups, save_now=True)
|
|
297
|
+ workspace = WorkspaceApi(
|
|
298
|
+ current_user=user,
|
|
299
|
+ session=self.session,
|
|
300
|
+ config=self.app_config,
|
|
301
|
+ ).create_workspace('test workspace', save_now=True)
|
|
302
|
+ api = ContentApi(
|
|
303
|
+ current_user=user,
|
|
304
|
+ session=self.session,
|
|
305
|
+ config=self.app_config,
|
|
306
|
+ )
|
|
307
|
+ folder = api.create(
|
|
308
|
+ content_type_slug=CONTENT_TYPES.Folder.slug,
|
|
309
|
+ workspace=workspace,
|
|
310
|
+ parent=None,
|
|
311
|
+ label='plop',
|
|
312
|
+ do_save=False
|
|
313
|
+ )
|
|
314
|
+ allowed_content_dict = {CONTENT_TYPES.Folder.slug: True, CONTENT_TYPES.File.slug: False} # nopep8
|
|
315
|
+ api._set_allowed_content(
|
|
316
|
+ folder,
|
|
317
|
+ allowed_content_dict=allowed_content_dict
|
|
318
|
+ )
|
|
319
|
+ assert 'allowed_content' in folder.properties
|
|
320
|
+ assert folder.properties['allowed_content'] == {CONTENT_TYPES.Folder.slug: True, CONTENT_TYPES.File.slug: False}
|
|
321
|
+
|
|
322
|
+ def test_unit__set_allowed_content__ok__nominal_case(self):
|
|
323
|
+ uapi = UserApi(
|
|
324
|
+ session=self.session,
|
|
325
|
+ config=self.app_config,
|
|
326
|
+ current_user=None,
|
|
327
|
+ )
|
|
328
|
+ group_api = GroupApi(
|
|
329
|
+ current_user=None,
|
|
330
|
+ session=self.session,
|
|
331
|
+ config=self.app_config,
|
|
332
|
+ )
|
|
333
|
+ groups = [group_api.get_one(Group.TIM_USER),
|
|
334
|
+ group_api.get_one(Group.TIM_MANAGER),
|
|
335
|
+ group_api.get_one(Group.TIM_ADMIN)]
|
|
336
|
+
|
|
337
|
+ user = uapi.create_minimal_user(email='this.is@user',
|
|
338
|
+ groups=groups, save_now=True)
|
|
339
|
+ workspace = WorkspaceApi(
|
|
340
|
+ current_user=user,
|
|
341
|
+ session=self.session,
|
|
342
|
+ config=self.app_config,
|
|
343
|
+ ).create_workspace('test workspace', save_now=True)
|
|
344
|
+ api = ContentApi(
|
|
345
|
+ current_user=user,
|
|
346
|
+ session=self.session,
|
|
347
|
+ config=self.app_config,
|
|
348
|
+ )
|
|
349
|
+ folder = api.create(
|
|
350
|
+ content_type_slug=CONTENT_TYPES.Folder.slug,
|
|
351
|
+ workspace=workspace,
|
|
352
|
+ parent=None,
|
|
353
|
+ label='plop',
|
|
354
|
+ do_save=False
|
|
355
|
+ )
|
|
356
|
+ allowed_content_type_slug_list = [CONTENT_TYPES.Folder.slug, CONTENT_TYPES.File.slug] # nopep8
|
|
357
|
+ api.set_allowed_content(
|
|
358
|
+ folder,
|
|
359
|
+ allowed_content_type_slug_list=allowed_content_type_slug_list
|
|
360
|
+ )
|
|
361
|
+ assert 'allowed_content' in folder.properties
|
|
362
|
+ assert folder.properties['allowed_content'] == {CONTENT_TYPES.Folder.slug: True, CONTENT_TYPES.File.slug: True}
|
|
363
|
+
|
|
364
|
+ def test_unit__restore_content_default_allowed_content__ok__nominal_case(self):
|
|
365
|
+ uapi = UserApi(
|
|
366
|
+ session=self.session,
|
|
367
|
+ config=self.app_config,
|
|
368
|
+ current_user=None,
|
|
369
|
+ )
|
|
370
|
+ group_api = GroupApi(
|
|
371
|
+ current_user=None,
|
|
372
|
+ session=self.session,
|
|
373
|
+ config=self.app_config,
|
|
374
|
+ )
|
|
375
|
+ groups = [group_api.get_one(Group.TIM_USER),
|
|
376
|
+ group_api.get_one(Group.TIM_MANAGER),
|
|
377
|
+ group_api.get_one(Group.TIM_ADMIN)]
|
|
378
|
+
|
|
379
|
+ user = uapi.create_minimal_user(email='this.is@user',
|
|
380
|
+ groups=groups, save_now=True)
|
|
381
|
+ workspace = WorkspaceApi(
|
|
382
|
+ current_user=user,
|
|
383
|
+ session=self.session,
|
|
384
|
+ config=self.app_config,
|
|
385
|
+ ).create_workspace('test workspace', save_now=True)
|
|
386
|
+ api = ContentApi(
|
|
387
|
+ current_user=user,
|
|
388
|
+ session=self.session,
|
|
389
|
+ config=self.app_config,
|
|
390
|
+ )
|
|
391
|
+ folder = api.create(
|
|
392
|
+ content_type_slug=CONTENT_TYPES.Folder.slug,
|
|
393
|
+ workspace=workspace,
|
|
394
|
+ parent=None,
|
|
395
|
+ label='plop',
|
|
396
|
+ do_save=False
|
|
397
|
+ )
|
|
398
|
+ allowed_content_type_slug_list = [CONTENT_TYPES.Folder.slug, CONTENT_TYPES.File.slug] # nopep8
|
|
399
|
+ api.set_allowed_content(
|
|
400
|
+ folder,
|
|
401
|
+ allowed_content_type_slug_list=allowed_content_type_slug_list
|
|
402
|
+ )
|
|
403
|
+ assert 'allowed_content' in folder.properties
|
|
404
|
+ assert folder.properties['allowed_content'] == {CONTENT_TYPES.Folder.slug: True, CONTENT_TYPES.File.slug: True} # nopep8
|
|
405
|
+ api.restore_content_default_allowed_content(folder)
|
|
406
|
+ assert 'allowed_content' in folder.properties
|
|
407
|
+ assert folder.properties['allowed_content'] == CONTENT_TYPES.default_allowed_content_properties(folder.type) # nopep8
|
279
|
408
|
|
280
|
409
|
def test_delete(self):
|
281
|
410
|
uapi = UserApi(
|