21
21
import pytest
22
22
23
23
from umapi_client import IdentityTypes , GroupTypes , RoleTypes
24
- from umapi_client import UserAction
24
+ from umapi_client import UserAction , UserGroupAction
25
25
26
26
27
27
def test_user_emptyid ():
28
28
with pytest .raises (ValueError ):
29
- user = UserAction (id_type = IdentityTypes .federatedID )
29
+ UserAction (id_type = IdentityTypes .federatedID )
30
30
31
31
32
32
def test_user_adobeid ():
@@ -43,7 +43,7 @@ def test_user_enterpriseid():
43
43
44
44
def test_user_enterpriseid_username ():
45
45
with pytest .raises (ValueError ):
46
- user = UserAction (id_type = IdentityTypes .enterpriseID , username = "dbrotsky" , domain = "o.on-the-side.net" )
46
+ UserAction (id_type = IdentityTypes .enterpriseID , username = "dbrotsky" , domain = "o.on-the-side.net" )
47
47
48
48
49
49
def test_user_federatedid ():
@@ -98,7 +98,7 @@ def test_create_user_federatedid_username():
98
98
99
99
100
100
def test_create_user_federatedid_username_email ():
101
- user = UserAction (id_type = IdentityTypes .federatedID ,username = "dbrotsky" , domain = "k.on-the-side.net" ,
101
+ user = UserAction (id_type = IdentityTypes .federatedID , username = "dbrotsky" , domain = "k.on-the-side.net" ,
102
102
103
103
user .create (first_name = "Daniel" , last_name = "Brotsky" , country = "US" )
104
104
assert user .
wire_dict ()
== {
"do" : [{
"createFederatedID" : {
"email" :
"[email protected] " ,
@@ -134,47 +134,73 @@ def test_update_user_federatedid_username():
134
134
135
135
136
136
137
- def test_add_product_federatedid ():
137
+ def test_add_org_federatedid ():
138
+ user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
139
+ user .add_to_groups ()
140
+ assert user .wire_dict () == {"do" : [{"add" : {"product" : []}}],
141
+
142
+
143
+
144
+ def test_add_products_federatedid ():
138
145
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
139
- user .add_group (groups = ["Photoshop" , "Illustrator" ])
146
+ user .add_to_groups (groups = ["Photoshop" , "Illustrator" ])
140
147
assert user .wire_dict () == {"do" : [{"add" : {"product" : ["Photoshop" , "Illustrator" ]}}],
141
148
142
149
143
150
144
- def test_add_usergroup_federatedid ():
151
+ def test_add_to_groups_federatedid_all ():
152
+ user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
153
+ user .add_to_groups (all_groups = True )
154
+ assert user .wire_dict () == {"do" : [{"add" : "all" }],
155
+
156
+
157
+
158
+ def test_add_to_groups_federatedid_all_error ():
159
+ user = UserAction (
id_type = "federatedID" ,
email = "[email protected] " )
160
+ with pytest .raises (ValueError ):
161
+ user .add_to_groups (all_groups = True , groups = ["Photoshop" ])
162
+
163
+
164
+ def test_add_to_usergroups_federatedid ():
145
165
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
146
- user .add_group (groups = ["Photoshop" , "Illustrator" ], group_type = GroupTypes .usergroup )
166
+ user .add_to_groups (groups = ["Photoshop" , "Illustrator" ], group_type = GroupTypes .usergroup )
147
167
assert user .wire_dict () == {"do" : [{"add" : {"usergroup" : ["Photoshop" , "Illustrator" ]}}],
148
168
149
169
150
170
151
- def test_remove_product_federatedid ():
171
+ def test_remove_from_products_federatedid ():
152
172
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
153
- user .remove_group (groups = ["Photoshop" , "Illustrator" ], group_type = "product" )
173
+ user .remove_from_groups (groups = ["Photoshop" , "Illustrator" ], group_type = "product" )
154
174
assert user .wire_dict () == {"do" : [{"remove" : {"product" : ["Photoshop" , "Illustrator" ]}}],
155
175
156
176
157
177
158
- def test_remove_groups_federatedid_all ():
178
+ def test_remove_from_groups_federatedid_all ():
159
179
user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
160
- user .remove_group (all_groups = True )
180
+ user .remove_from_groups (all_groups = True )
161
181
assert user .wire_dict () == {"do" : [{"remove" : "all" }],
162
182
163
183
164
184
165
- def test_remove_groups_federatedid_all_error ():
185
+ def test_remove_from_groups_federatedid_all_error ():
166
186
user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
167
187
with pytest .raises (ValueError ):
168
- user .remove_group (all_groups = True , group_type = "usergroup" )
188
+ user .remove_from_groups (all_groups = True , group_type = "usergroup" )
169
189
170
190
171
191
def test_add_role_enterpriseid ():
172
192
user = UserAction (
id_type = IdentityTypes .
enterpriseID ,
email = "[email protected] " )
173
- user .add_role (groups = ["Photoshop" , "Illustrator" ], role_type = RoleTypes . admin )
193
+ user .add_role (groups = ["Photoshop" , "Illustrator" ])
174
194
assert user .wire_dict () == {"do" : [{"addRoles" : {"admin" : ["Photoshop" , "Illustrator" ]}}],
175
195
176
196
177
197
198
+ def test_add_role_enterpriseid_error ():
199
+ user = UserAction (
id_type = IdentityTypes .
enterpriseID ,
email = "[email protected] " )
200
+ with pytest .raises (ValueError ):
201
+ user .add_role (groups = [], role_type = RoleTypes .admin )
202
+
203
+
178
204
def test_remove_role_enterpriseid ():
179
205
user = UserAction (
id_type = 'enterpriseID' ,
email = "[email protected] " )
180
206
user .remove_role (groups = ["Photoshop" , "Illustrator" ], role_type = "productAdmin" )
@@ -221,3 +247,69 @@ def test_delete_account_adobeid():
221
247
user = UserAction (
id_type = IdentityTypes .
adobeID ,
email = "[email protected] " )
222
248
with pytest .raises (ValueError ):
223
249
user .delete_account ()
250
+
251
+
252
+ def test_add_to_products ():
253
+ group = UserGroupAction (group_name = "SampleUsers" )
254
+ group .add_to_products (products = ["Photoshop" , "Illustrator" ])
255
+ assert group .wire_dict () == {"do" : [{"add" : {"product" : ["Photoshop" , "Illustrator" ]}}],
256
+ "usergroup" : "SampleUsers" }
257
+
258
+
259
+ def test_add_to_products_all ():
260
+ group = UserGroupAction (group_name = "SampleUsers" )
261
+ group .add_to_products (all_products = True )
262
+ assert group .wire_dict () == {"do" : [{"add" : "all" }],
263
+ "usergroup" : "SampleUsers" }
264
+
265
+
266
+ def test_add_to_products_all_error ():
267
+ group = UserGroupAction (group_name = "SampleUsers" )
268
+ with pytest .raises (ValueError ):
269
+ group .add_to_products (all_products = True , products = ["Photoshop" ])
270
+
271
+
272
+ def test_remove_from_products ():
273
+ group = UserGroupAction (group_name = "SampleUsers" )
274
+ group .remove_from_products (products = ["Photoshop" , "Illustrator" ])
275
+ assert group .wire_dict () == {"do" : [{"remove" : {"product" : ["Photoshop" , "Illustrator" ]}}],
276
+ "usergroup" : "SampleUsers" }
277
+
278
+
279
+ def test_remove_from_products_all ():
280
+ group = UserGroupAction (group_name = "SampleUsers" )
281
+ group .remove_from_products (all_products = True )
282
+ assert group .wire_dict () == {"do" : [{"remove" : "all" }],
283
+ "usergroup" : "SampleUsers" }
284
+
285
+
286
+ def test_remove_from_products_all_error ():
287
+ group = UserGroupAction (group_name = "SampleUsers" )
288
+ with pytest .raises (ValueError ):
289
+ group .remove_from_products (all_products = True , products = ["Photoshop" ])
290
+
291
+
292
+ def test_add_users ():
293
+ group = UserGroupAction (group_name = "SampleUsers" )
294
+
295
+ assert group .
wire_dict ()
== {
"do" : [{
"add" : {
"user" : [
"[email protected] " ,
"[email protected] " ]}}],
296
+ "usergroup" : "SampleUsers" }
297
+
298
+
299
+ def test_add_users_error ():
300
+ group = UserGroupAction (group_name = "SampleUsers" )
301
+ with pytest .raises (ValueError ):
302
+ group .add_users (users = [])
303
+
304
+
305
+ def test_remove_users ():
306
+ group = UserGroupAction (group_name = "SampleUsers" )
307
+ group .
remove_users (
users = [
"[email protected] " ,
"[email protected] " ])
308
+ assert group .
wire_dict ()
== {
"do" : [{
"remove" : {
"user" : [
"[email protected] " ,
"[email protected] " ]}}],
309
+ "usergroup" : "SampleUsers" }
310
+
311
+
312
+ def test_remove_users_error ():
313
+ group = UserGroupAction (group_name = "SampleUsers" )
314
+ with pytest .raises (ValueError ):
315
+ group .remove_users (users = [])
0 commit comments