2121import pytest
2222
2323from umapi_client import IdentityTypes , GroupTypes , RoleTypes
24- from umapi_client import UserAction
24+ from umapi_client import UserAction , UserGroupAction
2525
2626
2727def test_user_emptyid ():
2828 with pytest .raises (ValueError ):
29- user = UserAction (id_type = IdentityTypes .federatedID )
29+ UserAction (id_type = IdentityTypes .federatedID )
3030
3131
3232def test_user_adobeid ():
@@ -43,7 +43,7 @@ def test_user_enterpriseid():
4343
4444def test_user_enterpriseid_username ():
4545 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" )
4747
4848
4949def test_user_federatedid ():
@@ -98,7 +98,7 @@ def test_create_user_federatedid_username():
9898
9999
100100def 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" ,
102102103103 user .create (first_name = "Daniel" , last_name = "Brotsky" , country = "US" )
104104 assert user .
wire_dict ()
== {
"do" : [{
"createFederatedID" : {
"email" :
"[email protected] " ,
@@ -134,47 +134,73 @@ def test_update_user_federatedid_username():
134134135135
136136
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 ():
138145 user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
139- user .add_group (groups = ["Photoshop" , "Illustrator" ])
146+ user .add_to_groups (groups = ["Photoshop" , "Illustrator" ])
140147 assert user .wire_dict () == {"do" : [{"add" : {"product" : ["Photoshop" , "Illustrator" ]}}],
141148142149
143150
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 ():
145165 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 )
147167 assert user .wire_dict () == {"do" : [{"add" : {"usergroup" : ["Photoshop" , "Illustrator" ]}}],
148168149169
150170
151- def test_remove_product_federatedid ():
171+ def test_remove_from_products_federatedid ():
152172 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" )
154174 assert user .wire_dict () == {"do" : [{"remove" : {"product" : ["Photoshop" , "Illustrator" ]}}],
155175156176
157177
158- def test_remove_groups_federatedid_all ():
178+ def test_remove_from_groups_federatedid_all ():
159179 user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
160- user .remove_group (all_groups = True )
180+ user .remove_from_groups (all_groups = True )
161181 assert user .wire_dict () == {"do" : [{"remove" : "all" }],
162182163183
164184
165- def test_remove_groups_federatedid_all_error ():
185+ def test_remove_from_groups_federatedid_all_error ():
166186 user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
167187 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" )
169189
170190
171191def test_add_role_enterpriseid ():
172192 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" ])
174194 assert user .wire_dict () == {"do" : [{"addRoles" : {"admin" : ["Photoshop" , "Illustrator" ]}}],
175195176196
177197
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+
178204def test_remove_role_enterpriseid ():
179205 user = UserAction (
id_type = 'enterpriseID' ,
email = "[email protected] " )
180206 user .remove_role (groups = ["Photoshop" , "Illustrator" ], role_type = "productAdmin" )
@@ -221,3 +247,69 @@ def test_delete_account_adobeid():
221247 user = UserAction (
id_type = IdentityTypes .
adobeID ,
email = "[email protected] " )
222248 with pytest .raises (ValueError ):
223249 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