Skip to content

Commit c105957

Browse files
committed
Fix most of #1. Minor tweaks from testing.
* Cleaned up removefromorg, removefromdomain * Added all the group types and role types * Still need to add UserGroup actions * allowed for disabling timeouts for testing * make string delimiters consistent
1 parent 5f24bfd commit c105957

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

tests/test_functional.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pytest
2222

23-
from umapi_client import IdentityTypes
23+
from umapi_client import IdentityTypes, GroupTypes, RoleTypes
2424
from umapi_client import UserAction
2525

2626

@@ -31,7 +31,9 @@ def test_user_emptyid():
3131

3232
def test_user_adobeid():
3333
user = UserAction(email="[email protected]")
34-
assert user.wire_dict() == {"do": [], "user": "[email protected]"}
34+
assert user.wire_dict() == {"do": [],
35+
"user": "[email protected]",
36+
"useAdobeID": True}
3537

3638

3739
def test_user_enterpriseid():
@@ -58,7 +60,8 @@ def test_create_user_adobeid():
5860
user = UserAction(email="[email protected]")
5961
user.create()
6062
assert user.wire_dict() == {"do": [{"addAdobeID": {"email": "[email protected]"}}],
61-
"user": "[email protected]"}
63+
"user": "[email protected]",
64+
"useAdobeID": True}
6265

6366

6467
def test_create_user_adobeid_country():
@@ -138,31 +141,44 @@ def test_add_product_federatedid():
138141
"user": "[email protected]"}
139142

140143

144+
def test_add_usergroup_federatedid():
145+
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
146+
user.add_group(groups=["Photoshop", "Illustrator"], group_type=GroupTypes.usergroup)
147+
assert user.wire_dict() == {"do": [{"add": {"usergroup": ["Photoshop", "Illustrator"]}}],
148+
"user": "[email protected]"}
149+
150+
141151
def test_remove_product_federatedid():
142152
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
143-
user.remove_group(groups=["Photoshop", "Illustrator"])
153+
user.remove_group(groups=["Photoshop", "Illustrator"], group_type="product")
144154
assert user.wire_dict() == {"do": [{"remove": {"product": ["Photoshop", "Illustrator"]}}],
145155
"user": "[email protected]"}
146156

147157

148-
def test_remove_product_federatedid_all():
158+
def test_remove_groups_federatedid_all():
149159
user = UserAction(id_type='federatedID', email="[email protected]")
150160
user.remove_group(all_groups=True)
151161
assert user.wire_dict() == {"do": [{"remove": "all"}],
152162
"user": "[email protected]"}
153163

154164

165+
def test_remove_groups_federatedid_all_error():
166+
user = UserAction(id_type='federatedID', email="[email protected]")
167+
with pytest.raises(ValueError):
168+
user.remove_group(all_groups=True, group_type="usergroup")
169+
170+
155171
def test_add_role_enterpriseid():
156172
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
157-
user.add_role(groups=["Photoshop", "Illustrator"])
173+
user.add_role(groups=["Photoshop", "Illustrator"], role_type=RoleTypes.admin)
158174
assert user.wire_dict() == {"do": [{"addRoles": {"admin": ["Photoshop", "Illustrator"]}}],
159175
"user": "[email protected]"}
160176

161177

162178
def test_remove_role_enterpriseid():
163179
user = UserAction(id_type='enterpriseID', email="[email protected]")
164-
user.remove_role(groups=["Photoshop", "Illustrator"])
165-
assert user.wire_dict() == {"do": [{"removeRoles": {"admin": ["Photoshop", "Illustrator"]}}],
180+
user.remove_role(groups=["Photoshop", "Illustrator"], role_type="productAdmin")
181+
assert user.wire_dict() == {"do": [{"removeRoles": {"productAdmin": ["Photoshop", "Illustrator"]}}],
166182
"user": "[email protected]"}
167183

168184

@@ -177,13 +193,14 @@ def test_remove_from_organization_adobeid():
177193
user = UserAction(id_type='adobeID', email="[email protected]")
178194
user.remove_from_organization()
179195
assert user.wire_dict() == {"do": [{"removeFromOrg": {}}],
180-
"user": "[email protected]"}
196+
"user": "[email protected]",
197+
"useAdobeID": True}
181198

182199

183200
def test_remove_from_organization_delete_federatedid():
184201
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
185202
user.remove_from_organization(delete_account=True)
186-
assert user.wire_dict() == {"do": [{"removeFromOrg": {"removedDomain": "k.on-the-side.net"}}],
203+
assert user.wire_dict() == {"do": [{"removeFromOrg": {}}, {"removeFromDomain": {}}],
187204
"user": "[email protected]"}
188205

189206

@@ -196,7 +213,7 @@ def test_remove_from_organization_delete_adobeid():
196213
def test_delete_account_enterpriseid():
197214
user = UserAction(id_type=IdentityTypes.enterpriseID, email="[email protected]")
198215
user.delete_account()
199-
assert user.wire_dict() == {"do": [{"removeFromDomain": {"domain": "o.on-the-side.net"}}],
216+
assert user.wire_dict() == {"do": [{"removeFromDomain": {}}],
200217
"user": "[email protected]"}
201218

202219

0 commit comments

Comments
 (0)