Просмотр исходного кода

Tests getting notifiable roles

Adrien Panay 7 лет назад
Родитель
Сommit
3340e9ce61
2 измененных файлов: 25 добавлений и 3 удалений
  1. 2 0
      tracim/tracim/lib/userworkspace.py
  2. 23 3
      tracim/tracim/tests/library/test_workspace.py

+ 2 - 0
tracim/tracim/lib/userworkspace.py Просмотреть файл

@@ -86,6 +86,8 @@ class RoleApi(object):
86 86
     def get_one(self, user_id, workspace_id):
87 87
         return self._get_one_rsc(user_id, workspace_id).one()
88 88
 
89
+    # TODO - A.P - fix with_notif: bool vs with_notif: str
90
+    # https://github.com/tracim/tracim/issues/302
89 91
     def create_one(self, user: User, workspace: Workspace, role_level: int, with_notif: bool, flush: bool=True) -> UserRoleInWorkspace:
90 92
         role = self.create_role()
91 93
         role.user_id = user.user_id

+ 23 - 3
tracim/tracim/tests/library/test_workspace.py Просмотреть файл

@@ -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))