|
@@ -312,3 +312,158 @@ END:VCALENDAR
|
312
|
312
|
workspace_calendar_exist,
|
313
|
313
|
'Workspace calendar should be created',
|
314
|
314
|
)
|
|
315
|
+
|
|
316
|
+ def unit_test__disable_workspace_disable_file__ok__nominal_case(self):
|
|
317
|
+ self._connect_user(
|
|
318
|
+ 'admin@admin.admin',
|
|
319
|
+ 'admin@admin.admin',
|
|
320
|
+ )
|
|
321
|
+ radicale_workspaces_folder = '{0}/workspace'.format(
|
|
322
|
+ config.get('radicale.server.filesystem.folder'),
|
|
323
|
+ )
|
|
324
|
+ delete_radicale_workspaces_folder = '{0}/workspace/deleted'.format(
|
|
325
|
+ config.get('radicale.server.filesystem.folder'),
|
|
326
|
+ )
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+ self.app.post(
|
|
330
|
+ '/admin/workspaces',
|
|
331
|
+ OrderedDict([
|
|
332
|
+ ('name', 'WTESTCAL2'),
|
|
333
|
+ ('description', 'WTESTCAL2DESCR'),
|
|
334
|
+ ('calendar_enabled', 'on'),
|
|
335
|
+ ])
|
|
336
|
+ )
|
|
337
|
+ created_workspace = DBSession.query(Workspace)\
|
|
338
|
+ .filter(Workspace.label == 'WTESTCAL2')\
|
|
339
|
+ .one()
|
|
340
|
+ disable_response = self.app.put(
|
|
341
|
+ '/admin/workspaces/{}?_method=PUT'.format(
|
|
342
|
+ created_workspace.workspace_id,
|
|
343
|
+ ),
|
|
344
|
+ OrderedDict([
|
|
345
|
+ ('name', 'WTESTCAL2'),
|
|
346
|
+ ('description', 'WTESTCAL2DESCR'),
|
|
347
|
+ ('calendar_enabled', 'off'),
|
|
348
|
+ ])
|
|
349
|
+ )
|
|
350
|
+ eq_(disable_response.status_code, 302,
|
|
351
|
+ "Code should be 302, but is %d" % disable_response.status_code)
|
|
352
|
+ workspaces_calendars = [
|
|
353
|
+ name for name in
|
|
354
|
+ os.listdir(radicale_workspaces_folder)
|
|
355
|
+ if name.endswith('.ics')
|
|
356
|
+ ]
|
|
357
|
+ deleted_workspaces_calendars = [
|
|
358
|
+ name for name in
|
|
359
|
+ os.listdir(delete_radicale_workspaces_folder)
|
|
360
|
+ if name.endswith('.ics')
|
|
361
|
+ ]
|
|
362
|
+
|
|
363
|
+ eq_(
|
|
364
|
+ 0,
|
|
365
|
+ len(workspaces_calendars),
|
|
366
|
+ msg='No workspace ics file should exist, but {} found'.format(
|
|
367
|
+ len(workspaces_calendars),
|
|
368
|
+ ),
|
|
369
|
+ )
|
|
370
|
+ eq_(
|
|
371
|
+ 1,
|
|
372
|
+ len(deleted_workspaces_calendars),
|
|
373
|
+ msg='1 deleted workspace ics file should exist, but {} found'
|
|
374
|
+ .format(
|
|
375
|
+ len(deleted_workspaces_calendars),
|
|
376
|
+ ),
|
|
377
|
+ )
|
|
378
|
+ workspace_ics_file_name = '{}.ics'.format(
|
|
379
|
+ created_workspace.workspace_id
|
|
380
|
+ )
|
|
381
|
+ ok_(
|
|
382
|
+ workspace_ics_file_name in deleted_workspaces_calendars,
|
|
383
|
+ '{} should be in deleted workspace calendar folder'.format(
|
|
384
|
+ workspace_ics_file_name
|
|
385
|
+ ),
|
|
386
|
+ )
|
|
387
|
+
|
|
388
|
+ def unit_test__re_enable_workspace_re_enable_file__ok__nominal_case(self):
|
|
389
|
+ self._connect_user(
|
|
390
|
+ 'admin@admin.admin',
|
|
391
|
+ 'admin@admin.admin',
|
|
392
|
+ )
|
|
393
|
+ radicale_workspaces_folder = '{0}/workspace'.format(
|
|
394
|
+ config.get('radicale.server.filesystem.folder'),
|
|
395
|
+ )
|
|
396
|
+ delete_radicale_workspaces_folder = '{0}/workspace/deleted'.format(
|
|
397
|
+ config.get('radicale.server.filesystem.folder'),
|
|
398
|
+ )
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+ self.app.post(
|
|
403
|
+ '/admin/workspaces',
|
|
404
|
+ OrderedDict([
|
|
405
|
+ ('name', 'WTESTCAL2'),
|
|
406
|
+ ('description', 'WTESTCAL2DESCR'),
|
|
407
|
+ ('calendar_enabled', 'on'),
|
|
408
|
+ ])
|
|
409
|
+ )
|
|
410
|
+ created_workspace = DBSession.query(Workspace) \
|
|
411
|
+ .filter(Workspace.label == 'WTESTCAL2') \
|
|
412
|
+ .one()
|
|
413
|
+ self.app.put(
|
|
414
|
+ '/admin/workspaces/{}?_method=PUT'.format(
|
|
415
|
+ created_workspace.workspace_id,
|
|
416
|
+ ),
|
|
417
|
+ OrderedDict([
|
|
418
|
+ ('name', 'WTESTCAL2'),
|
|
419
|
+ ('description', 'WTESTCAL2DESCR'),
|
|
420
|
+ ('calendar_enabled', 'off'),
|
|
421
|
+ ])
|
|
422
|
+ )
|
|
423
|
+ re_enable_response = self.app.put(
|
|
424
|
+ '/admin/workspaces/{}?_method=PUT'.format(
|
|
425
|
+ created_workspace.workspace_id,
|
|
426
|
+ ),
|
|
427
|
+ OrderedDict([
|
|
428
|
+ ('name', 'WTESTCAL2'),
|
|
429
|
+ ('description', 'WTESTCAL2DESCR'),
|
|
430
|
+ ('calendar_enabled', 'on'),
|
|
431
|
+ ])
|
|
432
|
+ )
|
|
433
|
+ eq_(re_enable_response.status_code, 302,
|
|
434
|
+ "Code should be 302, but is %d" % re_enable_response.status_code)
|
|
435
|
+ workspaces_calendars = [
|
|
436
|
+ name for name in
|
|
437
|
+ os.listdir(radicale_workspaces_folder)
|
|
438
|
+ if name.endswith('.ics')
|
|
439
|
+ ]
|
|
440
|
+ deleted_workspaces_calendars = [
|
|
441
|
+ name for name in
|
|
442
|
+ os.listdir(delete_radicale_workspaces_folder)
|
|
443
|
+ if name.endswith('.ics')
|
|
444
|
+ ]
|
|
445
|
+
|
|
446
|
+ eq_(
|
|
447
|
+ 1,
|
|
448
|
+ len(workspaces_calendars),
|
|
449
|
+ msg='1 workspace ics file should exist, but {} found'.format(
|
|
450
|
+ len(workspaces_calendars),
|
|
451
|
+ ),
|
|
452
|
+ )
|
|
453
|
+ eq_(
|
|
454
|
+ 0,
|
|
455
|
+ len(deleted_workspaces_calendars),
|
|
456
|
+ msg='0 deleted workspace ics file should exist, but {} found'
|
|
457
|
+ .format(
|
|
458
|
+ len(deleted_workspaces_calendars),
|
|
459
|
+ ),
|
|
460
|
+ )
|
|
461
|
+ workspace_ics_file_name = '{}.ics'.format(
|
|
462
|
+ created_workspace.workspace_id
|
|
463
|
+ )
|
|
464
|
+ ok_(
|
|
465
|
+ workspace_ics_file_name in workspaces_calendars,
|
|
466
|
+ '{} should be in workspace calendar folder'.format(
|
|
467
|
+ workspace_ics_file_name
|
|
468
|
+ ),
|
|
469
|
+ )
|