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