Browse Source

Better doc + TODO comments

Guénaël Muller 6 years ago
parent
commit
46b044635d

+ 2 - 2
tracim/models/applications.py View File

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

+ 13 - 0
tracim/tests/functional/test_system.py View File

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

+ 25 - 3
tracim/tests/functional/test_user.py View File

@@ -1,14 +1,23 @@
1
-# coding=utf-8
1
+# -*- coding: utf-8 -*-
2
+"""
3
+Tests for /api/v2/users subpath endpoints.
4
+"""
2 5
 from tracim.tests import FunctionalTest
3 6
 from tracim.fixtures.content import Content as ContentFixtures
4 7
 from tracim.fixtures.users_and_groups import Base as BaseFixture
5 8
 
6 9
 
7 10
 class TestUserWorkspaceEndpoint(FunctionalTest):
8
-
11
+    # -*- coding: utf-8 -*-
12
+    """
13
+    Tests for /api/v2/users/{user_id}/workspaces
14
+    """
9 15
     fixtures = [BaseFixture, ContentFixtures]
10 16
 
11 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 21
         self.testapp.authorization = (
13 22
             'Basic',
14 23
             (
@@ -21,7 +30,7 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
21 30
         workspace = res[0]
22 31
         assert workspace['id'] == 1
23 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 35
         sidebar_entry = workspace['sidebar_entries'][0]
27 36
         assert sidebar_entry['slug'] == 'dashboard'
@@ -73,6 +82,10 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
73 82
         assert sidebar_entry['icon'] == "calendar-alt"
74 83
 
75 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 89
         self.testapp.authorization = (
77 90
             'Basic',
78 91
             (
@@ -87,6 +100,10 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
87 100
         assert 'details' in res.json.keys()
88 101
 
89 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 107
         self.testapp.authorization = (
91 108
             'Basic',
92 109
             (
@@ -101,6 +118,11 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
101 118
         assert 'details' in res.json.keys()
102 119
 
103 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 126
         self.testapp.authorization = (
105 127
             'Basic',
106 128
             (

+ 46 - 10
tracim/tests/functional/test_workspaces.py View File

@@ -1,15 +1,23 @@
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 5
 from tracim.tests import FunctionalTest
4 6
 from tracim.fixtures.content import Content as ContentFixtures
5 7
 from tracim.fixtures.users_and_groups import Base as BaseFixture
6 8
 
7 9
 
8 10
 class TestWorkspaceEndpoint(FunctionalTest):
11
+    """
12
+    Tests for /api/v2/workspaces/{workspace_id} endpoint
13
+    """
9 14
 
10 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 21
         self.testapp.authorization = (
14 22
             'Basic',
15 23
             (
@@ -23,7 +31,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
23 31
         assert workspace['slug'] == 'w1'
24 32
         assert workspace['label'] == 'w1'
25 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 36
         sidebar_entry = workspace['sidebar_entries'][0]
29 37
         assert sidebar_entry['slug'] == 'dashboard'
@@ -74,7 +82,10 @@ class TestWorkspaceEndpoint(FunctionalTest):
74 82
         assert sidebar_entry['hexcolor'] == "#757575"
75 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 89
         self.testapp.authorization = (
79 90
             'Basic',
80 91
             (
@@ -88,7 +99,10 @@ class TestWorkspaceEndpoint(FunctionalTest):
88 99
         assert 'message' in res.json.keys()
89 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 106
         self.testapp.authorization = (
93 107
             'Basic',
94 108
             (
@@ -102,7 +116,10 @@ class TestWorkspaceEndpoint(FunctionalTest):
102 116
         assert 'message' in res.json.keys()
103 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 123
         self.testapp.authorization = (
107 124
             'Basic',
108 125
             (
@@ -118,10 +135,16 @@ class TestWorkspaceEndpoint(FunctionalTest):
118 135
 
119 136
 
120 137
 class TestWorkspaceMembersEndpoint(FunctionalTest):
138
+    """
139
+    Tests for /api/v2/workspaces/{workspace_id}/members endpoint
140
+    """
121 141
 
122 142
     fixtures = [BaseFixture, ContentFixtures]
123 143
 
124 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 148
         self.testapp.authorization = (
126 149
             'Basic',
127 150
             (
@@ -129,16 +152,22 @@ class TestWorkspaceMembersEndpoint(FunctionalTest):
129 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 156
         assert len(res) == 2
134 157
         user_role = res[0]
135 158
         assert user_role['slug'] == 'workspace_manager'
136 159
         assert user_role['user_id'] == 1
137 160
         assert user_role['workspace_id'] == 1
138 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 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 171
         self.testapp.authorization = (
143 172
             'Basic',
144 173
             (
@@ -153,6 +182,9 @@ class TestWorkspaceMembersEndpoint(FunctionalTest):
153 182
         assert 'details' in res.json.keys()
154 183
 
155 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 188
         self.testapp.authorization = (
157 189
             'Basic',
158 190
             (
@@ -166,7 +198,11 @@ class TestWorkspaceMembersEndpoint(FunctionalTest):
166 198
         assert 'message' in res.json.keys()
167 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 206
         self.testapp.authorization = (
171 207
             'Basic',
172 208
             (

+ 1 - 1
tracim/views/core_api/schemas.py View File

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