瀏覽代碼

Better doc + TODO comments

Guénaël Muller 6 年之前
父節點
當前提交
46b044635d

+ 2 - 2
tracim/models/applications.py 查看文件

59
 )
59
 )
60
 
60
 
61
 pagemarkdownplus = Application(
61
 pagemarkdownplus = Application(
62
-    label='Rich Markdown Files',  # TODO : Better label
62
+    label='Rich Markdown Files',  # TODO - G.M - 24-05-2018 - Check label
63
     slug='contents/pagemarkdownplus',
63
     slug='contents/pagemarkdownplus',
64
     icon='file-code',
64
     icon='file-code',
65
     hexcolor='#f12d2d',
65
     hexcolor='#f12d2d',
69
 )
69
 )
70
 
70
 
71
 pagehtml = Application(
71
 pagehtml = Application(
72
-    label='Text Documents',  # TODO : Better label
72
+    label='Text Documents',  # TODO - G.M - 24-05-2018 - Check label
73
     slug='contents/pagehtml',
73
     slug='contents/pagehtml',
74
     icon='file-text-o',
74
     icon='file-text-o',
75
     hexcolor='#3f52e3',
75
     hexcolor='#3f52e3',

+ 13 - 0
tracim/tests/functional/test_system.py 查看文件

1
 # coding=utf-8
1
 # coding=utf-8
2
+"""
3
+Tests for /api/v2/system subpath endpoints.
4
+"""
2
 from tracim.tests import FunctionalTest
5
 from tracim.tests import FunctionalTest
3
 
6
 
4
 
7
 
5
 class TestApplicationsEndpoint(FunctionalTest):
8
 class TestApplicationsEndpoint(FunctionalTest):
9
+    """
10
+    Tests for /api/v2/system/applications
11
+    """
12
+
6
     def test_api__get_applications__ok_200__nominal_case(self):
13
     def test_api__get_applications__ok_200__nominal_case(self):
14
+        """
15
+        Get applications list with a registered user.
16
+        """
7
         self.testapp.authorization = (
17
         self.testapp.authorization = (
8
             'Basic',
18
             'Basic',
9
             (
19
             (
50
         assert 'config' in application
60
         assert 'config' in application
51
 
61
 
52
     def test_api__get_workspace__err_401__unregistered_user(self):
62
     def test_api__get_workspace__err_401__unregistered_user(self):
63
+        """
64
+        Get applications list with an unregistered user (bad auth)
65
+        """
53
         self.testapp.authorization = (
66
         self.testapp.authorization = (
54
             'Basic',
67
             'Basic',
55
             (
68
             (

+ 25 - 3
tracim/tests/functional/test_user.py 查看文件

1
-# coding=utf-8
1
+# -*- coding: utf-8 -*-
2
+"""
3
+Tests for /api/v2/users subpath endpoints.
4
+"""
2
 from tracim.tests import FunctionalTest
5
 from tracim.tests import FunctionalTest
3
 from tracim.fixtures.content import Content as ContentFixtures
6
 from tracim.fixtures.content import Content as ContentFixtures
4
 from tracim.fixtures.users_and_groups import Base as BaseFixture
7
 from tracim.fixtures.users_and_groups import Base as BaseFixture
5
 
8
 
6
 
9
 
7
 class TestUserWorkspaceEndpoint(FunctionalTest):
10
 class TestUserWorkspaceEndpoint(FunctionalTest):
8
-
11
+    # -*- coding: utf-8 -*-
12
+    """
13
+    Tests for /api/v2/users/{user_id}/workspaces
14
+    """
9
     fixtures = [BaseFixture, ContentFixtures]
15
     fixtures = [BaseFixture, ContentFixtures]
10
 
16
 
11
     def test_api__get_user_workspaces__ok_200__nominal_case(self):
17
     def test_api__get_user_workspaces__ok_200__nominal_case(self):
18
+        """
19
+        Check obtain all workspaces reachables for user with user auth.
20
+        """
12
         self.testapp.authorization = (
21
         self.testapp.authorization = (
13
             'Basic',
22
             'Basic',
14
             (
23
             (
21
         workspace = res[0]
30
         workspace = res[0]
22
         assert workspace['id'] == 1
31
         assert workspace['id'] == 1
23
         assert workspace['label'] == 'w1'
32
         assert workspace['label'] == 'w1'
24
-        assert len(workspace['sidebar_entries']) == 7  # TODO change this
33
+        assert len(workspace['sidebar_entries']) == 7
25
 
34
 
26
         sidebar_entry = workspace['sidebar_entries'][0]
35
         sidebar_entry = workspace['sidebar_entries'][0]
27
         assert sidebar_entry['slug'] == 'dashboard'
36
         assert sidebar_entry['slug'] == 'dashboard'
73
         assert sidebar_entry['icon'] == "calendar-alt"
82
         assert sidebar_entry['icon'] == "calendar-alt"
74
 
83
 
75
     def test_api__get_user_workspaces__err_403__unallowed_user(self):
84
     def test_api__get_user_workspaces__err_403__unallowed_user(self):
85
+        """
86
+        Check obtain all workspaces reachables for one user
87
+        with another non-admin user auth.
88
+        """
76
         self.testapp.authorization = (
89
         self.testapp.authorization = (
77
             'Basic',
90
             'Basic',
78
             (
91
             (
87
         assert 'details' in res.json.keys()
100
         assert 'details' in res.json.keys()
88
 
101
 
89
     def test_api__get_user_workspaces__err_401__unregistered_user(self):
102
     def test_api__get_user_workspaces__err_401__unregistered_user(self):
103
+        """
104
+        Check obtain all workspaces reachables for one user
105
+        without correct user auth (user unregistered).
106
+        """
90
         self.testapp.authorization = (
107
         self.testapp.authorization = (
91
             'Basic',
108
             'Basic',
92
             (
109
             (
101
         assert 'details' in res.json.keys()
118
         assert 'details' in res.json.keys()
102
 
119
 
103
     def test_api__get_user_workspaces__err_404__user_does_not_exist(self):
120
     def test_api__get_user_workspaces__err_404__user_does_not_exist(self):
121
+        """
122
+        Check obtain all workspaces reachables for one user who does
123
+        not exist
124
+        with a correct user auth.
125
+        """
104
         self.testapp.authorization = (
126
         self.testapp.authorization = (
105
             'Basic',
127
             'Basic',
106
             (
128
             (

+ 46 - 10
tracim/tests/functional/test_workspaces.py 查看文件

1
-# coding=utf-8
2
-from tracim.models.data import UserRoleInWorkspace
1
+# -*- coding: utf-8 -*-
2
+"""
3
+Tests for /api/v2/workspaces subpath endpoints.
4
+"""
3
 from tracim.tests import FunctionalTest
5
 from tracim.tests import FunctionalTest
4
 from tracim.fixtures.content import Content as ContentFixtures
6
 from tracim.fixtures.content import Content as ContentFixtures
5
 from tracim.fixtures.users_and_groups import Base as BaseFixture
7
 from tracim.fixtures.users_and_groups import Base as BaseFixture
6
 
8
 
7
 
9
 
8
 class TestWorkspaceEndpoint(FunctionalTest):
10
 class TestWorkspaceEndpoint(FunctionalTest):
11
+    """
12
+    Tests for /api/v2/workspaces/{workspace_id} endpoint
13
+    """
9
 
14
 
10
     fixtures = [BaseFixture, ContentFixtures]
15
     fixtures = [BaseFixture, ContentFixtures]
11
 
16
 
12
-    def test_api__get_workspace__ok_200__nominal_case(self):
17
+    def test_api__get_workspace__ok_200__nominal_case(self) -> None:
18
+        """
19
+        Check obtain workspace reachable for user.
20
+        """
13
         self.testapp.authorization = (
21
         self.testapp.authorization = (
14
             'Basic',
22
             'Basic',
15
             (
23
             (
23
         assert workspace['slug'] == 'w1'
31
         assert workspace['slug'] == 'w1'
24
         assert workspace['label'] == 'w1'
32
         assert workspace['label'] == 'w1'
25
         assert workspace['description'] == 'This is a workspace'
33
         assert workspace['description'] == 'This is a workspace'
26
-        assert len(workspace['sidebar_entries']) == 7  # TODO change this
34
+        assert len(workspace['sidebar_entries']) == 7
27
 
35
 
28
         sidebar_entry = workspace['sidebar_entries'][0]
36
         sidebar_entry = workspace['sidebar_entries'][0]
29
         assert sidebar_entry['slug'] == 'dashboard'
37
         assert sidebar_entry['slug'] == 'dashboard'
74
         assert sidebar_entry['hexcolor'] == "#757575"
82
         assert sidebar_entry['hexcolor'] == "#757575"
75
         assert sidebar_entry['icon'] == "calendar-alt"
83
         assert sidebar_entry['icon'] == "calendar-alt"
76
 
84
 
77
-    def test_api__get_workspace__err_403__unallowed_user(self):
85
+    def test_api__get_workspace__err_403__unallowed_user(self) -> None:
86
+        """
87
+        Check obtain workspace unreachable for user
88
+        """
78
         self.testapp.authorization = (
89
         self.testapp.authorization = (
79
             'Basic',
90
             'Basic',
80
             (
91
             (
88
         assert 'message' in res.json.keys()
99
         assert 'message' in res.json.keys()
89
         assert 'details' in res.json.keys()
100
         assert 'details' in res.json.keys()
90
 
101
 
91
-    def test_api__get_workspace__err_401__unregistered_user(self):
102
+    def test_api__get_workspace__err_401__unregistered_user(self) -> None:
103
+        """
104
+        Check obtain workspace without registered user.
105
+        """
92
         self.testapp.authorization = (
106
         self.testapp.authorization = (
93
             'Basic',
107
             'Basic',
94
             (
108
             (
102
         assert 'message' in res.json.keys()
116
         assert 'message' in res.json.keys()
103
         assert 'details' in res.json.keys()
117
         assert 'details' in res.json.keys()
104
 
118
 
105
-    def test_api__get_workspace__err_403__workspace_does_not_exist(self):
119
+    def test_api__get_workspace__err_403__workspace_does_not_exist(self) -> None:  # nopep8
120
+        """
121
+        Check obtain workspace who does not exist with an existing user.
122
+        """
106
         self.testapp.authorization = (
123
         self.testapp.authorization = (
107
             'Basic',
124
             'Basic',
108
             (
125
             (
118
 
135
 
119
 
136
 
120
 class TestWorkspaceMembersEndpoint(FunctionalTest):
137
 class TestWorkspaceMembersEndpoint(FunctionalTest):
138
+    """
139
+    Tests for /api/v2/workspaces/{workspace_id}/members endpoint
140
+    """
121
 
141
 
122
     fixtures = [BaseFixture, ContentFixtures]
142
     fixtures = [BaseFixture, ContentFixtures]
123
 
143
 
124
     def test_api__get_workspace_members__ok_200__nominal_case(self):
144
     def test_api__get_workspace_members__ok_200__nominal_case(self):
145
+        """
146
+        Check obtain workspace members list with a reachable workspace for user
147
+        """
125
         self.testapp.authorization = (
148
         self.testapp.authorization = (
126
             'Basic',
149
             'Basic',
127
             (
150
             (
129
                 'admin@admin.admin'
152
                 'admin@admin.admin'
130
             )
153
             )
131
         )
154
         )
132
-        res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body
155
+        res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
133
         assert len(res) == 2
156
         assert len(res) == 2
134
         user_role = res[0]
157
         user_role = res[0]
135
         assert user_role['slug'] == 'workspace_manager'
158
         assert user_role['slug'] == 'workspace_manager'
136
         assert user_role['user_id'] == 1
159
         assert user_role['user_id'] == 1
137
         assert user_role['workspace_id'] == 1
160
         assert user_role['workspace_id'] == 1
138
         assert user_role['user']['display_name'] == 'Global manager'
161
         assert user_role['user']['display_name'] == 'Global manager'
139
-        assert user_role['user']['avatar_url'] is None  # TODO
162
+        # TODO - G.M - 24-05-2018 - [Avatar] Replace
163
+        # by correct value when avatar feature will be enabled
164
+        assert user_role['user']['avatar_url'] is None
140
 
165
 
141
     def test_api__get_workspace_members__err_403__unallowed_user(self):
166
     def test_api__get_workspace_members__err_403__unallowed_user(self):
167
+        """
168
+        Check obtain workspace members list with an unreachable workspace for
169
+        user
170
+        """
142
         self.testapp.authorization = (
171
         self.testapp.authorization = (
143
             'Basic',
172
             'Basic',
144
             (
173
             (
153
         assert 'details' in res.json.keys()
182
         assert 'details' in res.json.keys()
154
 
183
 
155
     def test_api__get_workspace_members__err_401__unregistered_user(self):
184
     def test_api__get_workspace_members__err_401__unregistered_user(self):
185
+        """
186
+        Check obtain workspace members list with an unregistered user
187
+        """
156
         self.testapp.authorization = (
188
         self.testapp.authorization = (
157
             'Basic',
189
             'Basic',
158
             (
190
             (
166
         assert 'message' in res.json.keys()
198
         assert 'message' in res.json.keys()
167
         assert 'details' in res.json.keys()
199
         assert 'details' in res.json.keys()
168
 
200
 
169
-    def test_api__get_workspace_members__err_403__workspace_does_not_exist(self):
201
+    def test_api__get_workspace_members__err_403__workspace_does_not_exist(self):  # nopep8
202
+        """
203
+        Check obtain workspace members list with an existing user but
204
+        an unexisting workspace
205
+        """
170
         self.testapp.authorization = (
206
         self.testapp.authorization = (
171
             'Basic',
207
             'Basic',
172
             (
208
             (

+ 1 - 1
tracim/views/core_api/schemas.py 查看文件

97
 
97
 
98
 class ApplicationConfigSchema(marshmallow.Schema):
98
 class ApplicationConfigSchema(marshmallow.Schema):
99
     pass
99
     pass
100
-    #  TODO
100
+    #  TODO - G.M - 24-05-2018 - Set this
101
 
101
 
102
 
102
 
103
 class ApplicationSchema(marshmallow.Schema):
103
 class ApplicationSchema(marshmallow.Schema):