|
@@ -1,11 +1,17 @@
|
1
|
1
|
# -*- coding: utf-8 -*-
|
2
|
|
-import transaction
|
3
|
2
|
from nose.tools import eq_
|
4
|
3
|
|
5
|
4
|
from tracim.lib.content import ContentApi
|
6
|
|
-from tracim.model import DBSession, Content, User
|
|
5
|
+from tracim.lib.user import UserApi
|
|
6
|
+from tracim.lib.userworkspace import RoleApi
|
|
7
|
+from tracim.lib.workspace import WorkspaceApi
|
|
8
|
+from tracim.model import Content
|
|
9
|
+from tracim.model import DBSession
|
|
10
|
+from tracim.model import User
|
|
11
|
+from tracim.model.data import UserRoleInWorkspace
|
7
|
12
|
from tracim.model.data import Workspace
|
8
|
|
-from tracim.tests import BaseTestThread, TestStandard
|
|
13
|
+from tracim.tests import BaseTestThread
|
|
14
|
+from tracim.tests import TestStandard
|
9
|
15
|
|
10
|
16
|
|
11
|
17
|
class TestThread(BaseTestThread, TestStandard):
|
|
@@ -21,3 +27,17 @@ class TestThread(BaseTestThread, TestStandard):
|
21
|
27
|
workspace = DBSession.query(Workspace).filter(Workspace.label == 'workspace_1').one()
|
22
|
28
|
folder = ContentApi.get_canonical_query().filter(Content.label == 'folder_1').one()
|
23
|
29
|
eq_([folder, ], list(workspace.get_valid_children()))
|
|
30
|
+
|
|
31
|
+ def test_get_notifiable_roles(self):
|
|
32
|
+ admin = DBSession.query(User) \
|
|
33
|
+ .filter(User.email == 'admin@admin.admin').one()
|
|
34
|
+ wapi = WorkspaceApi(admin)
|
|
35
|
+ w = wapi.create_workspace(label='workspace w', save_now=True)
|
|
36
|
+ uapi = UserApi(admin)
|
|
37
|
+ u = uapi.create_user(email='u.u@u.u', save_now=True)
|
|
38
|
+ eq_([], wapi.get_notifiable_roles(workspace=w))
|
|
39
|
+ rapi = RoleApi(u)
|
|
40
|
+ r = rapi.create_one(u, w, UserRoleInWorkspace.READER, with_notif='on')
|
|
41
|
+ eq_([r, ], wapi.get_notifiable_roles(workspace=w))
|
|
42
|
+ u.is_active = False
|
|
43
|
+ eq_([], wapi.get_notifiable_roles(workspace=w))
|