@@ -152,3 +152,97 @@ def test_populate_workbooks(self):
152
152
TSC .Permission .Capability .AddComment : TSC .Permission .Mode .Allow ,
153
153
TSC .Permission .Capability .ChangeHierarchy : TSC .Permission .Mode .Allow ,
154
154
})
155
+
156
+ def test_delete_permission (self ):
157
+ with open (asset (POPULATE_PERMISSIONS_XML ), 'rb' ) as f :
158
+ response_xml = f .read ().decode ('utf-8' )
159
+ with requests_mock .mock () as m :
160
+ m .get (self .baseurl + '/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions' , text = response_xml )
161
+
162
+ single_group = TSC .GroupItem ('Group1' )
163
+ single_group ._id = 'c8f2773a-c83a-11e8-8c8f-33e6d787b506'
164
+
165
+ single_project = TSC .ProjectItem ('Project3' )
166
+ single_project ._id = '0448d2ed-590d-4fa0-b272-a2a8a24555b5'
167
+
168
+ self .server .projects .populate_permissions (single_project )
169
+ permissions = single_project .permissions
170
+
171
+ capabilities = {}
172
+
173
+ for permission in permissions :
174
+ if permission .grantee .tag_name == "group" :
175
+ if permission .grantee .id == single_group ._id :
176
+ capabilities = permission .capabilities
177
+
178
+ rules = TSC .PermissionsRule (
179
+ grantee = single_group ,
180
+ capabilities = capabilities
181
+ )
182
+
183
+ endpoint = '{}/permissions/groups/{}' .format (single_project ._id , single_group ._id )
184
+ m .delete ('{}/{}/Read/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
185
+ m .delete ('{}/{}/Write/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
186
+ self .server .projects .delete_permission (item = single_project , rules = rules )
187
+
188
+ def test_delete_workbook_default_permission (self ):
189
+ with open (asset (POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML ), 'rb' ) as f :
190
+ response_xml = f .read ().decode ('utf-8' )
191
+
192
+ with requests_mock .mock () as m :
193
+ m .get (self .baseurl + '/9dbd2263-16b5-46e1-9c43-a76bb8ab65fb/default-permissions/workbooks' ,
194
+ text = response_xml )
195
+
196
+ single_group = TSC .GroupItem ('Group1' )
197
+ single_group ._id = 'c8f2773a-c83a-11e8-8c8f-33e6d787b506'
198
+
199
+ single_project = TSC .ProjectItem ('test' , '1d0304cd-3796-429f-b815-7258370b9b74' )
200
+ single_project .owner_id = 'dd2239f6-ddf1-4107-981a-4cf94e415794'
201
+ single_project ._id = '9dbd2263-16b5-46e1-9c43-a76bb8ab65fb'
202
+
203
+ self .server .projects .populate_workbook_default_permissions (single_project )
204
+ permissions = single_project .default_workbook_permissions
205
+
206
+ capabilities = {
207
+ # View
208
+ TSC .Permission .Capability .Read : TSC .Permission .Mode .Allow ,
209
+ TSC .Permission .Capability .ExportImage : TSC .Permission .Mode .Allow ,
210
+ TSC .Permission .Capability .ExportData : TSC .Permission .Mode .Allow ,
211
+ TSC .Permission .Capability .ViewComments : TSC .Permission .Mode .Allow ,
212
+ TSC .Permission .Capability .AddComment : TSC .Permission .Mode .Allow ,
213
+
214
+ # Interact/Edit
215
+ TSC .Permission .Capability .Filter : TSC .Permission .Mode .Allow ,
216
+ TSC .Permission .Capability .ViewUnderlyingData : TSC .Permission .Mode .Deny ,
217
+ TSC .Permission .Capability .ShareView : TSC .Permission .Mode .Allow ,
218
+ TSC .Permission .Capability .WebAuthoring : TSC .Permission .Mode .Allow ,
219
+
220
+ # Edit
221
+ TSC .Permission .Capability .Write : TSC .Permission .Mode .Allow ,
222
+ TSC .Permission .Capability .ExportXml : TSC .Permission .Mode .Allow ,
223
+ TSC .Permission .Capability .ChangeHierarchy : TSC .Permission .Mode .Allow ,
224
+ TSC .Permission .Capability .Delete : TSC .Permission .Mode .Deny ,
225
+ TSC .Permission .Capability .ChangePermissions : TSC .Permission .Mode .Allow
226
+ }
227
+
228
+ rules = TSC .PermissionsRule (
229
+ grantee = single_group ,
230
+ capabilities = capabilities
231
+ )
232
+
233
+ endpoint = '{}/default-permissions/workbook/groups/{}' .format (single_project ._id , single_group ._id )
234
+ m .delete ('{}/{}/Read/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
235
+ m .delete ('{}/{}/ExportImage/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
236
+ m .delete ('{}/{}/ExportData/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
237
+ m .delete ('{}/{}/ViewComments/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
238
+ m .delete ('{}/{}/AddComment/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
239
+ m .delete ('{}/{}/Filter/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
240
+ m .delete ('{}/{}/ViewUnderlyingData/Deny' .format (self .baseurl , endpoint ), status_code = 204 )
241
+ m .delete ('{}/{}/ShareView/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
242
+ m .delete ('{}/{}/WebAuthoring/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
243
+ m .delete ('{}/{}/Write/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
244
+ m .delete ('{}/{}/ExportXml/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
245
+ m .delete ('{}/{}/ChangeHierarchy/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
246
+ m .delete ('{}/{}/Delete/Deny' .format (self .baseurl , endpoint ), status_code = 204 )
247
+ m .delete ('{}/{}/ChangePermissions/Allow' .format (self .baseurl , endpoint ), status_code = 204 )
248
+ self .server .projects .delete_workbook_default_permissions (item = single_project , rule = rules )
0 commit comments