Skip to content

Commit 12c5699

Browse files
Merge pull request #74 from Luci2015/v2
fix for #73
2 parents 1c446d7 + 613a4a1 commit 12c5699

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

tests/test_connections.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,13 @@ def test_complex_group_split():
416416
user.commands = [{
417417
"add": {
418418
GroupTypes.usergroup.name: add_groups,
419-
GroupTypes.product.name: add_products,
419+
GroupTypes.group.name: add_products,
420420
},
421421
}]
422422
assert user.maybe_split_groups(10) is True
423423
assert len(user.commands) == 15
424-
assert len([c for c in user.commands if 'product' in c['add']]) == 3
425-
assert GroupTypes.product.name not in user.commands[3]['add']
424+
assert len([c for c in user.commands if 'group' in c['add']]) == 3
425+
assert GroupTypes.group.name not in user.commands[3]['add']
426426

427427

428428
def test_split_remove_all():
@@ -439,7 +439,7 @@ def test_split_remove_all():
439439
user.add_to_groups(groups=add_groups)
440440
assert user.maybe_split_groups(10) is True
441441
assert user.wire_dict() == {'do': [{'remove': 'all'},
442-
{'add': {'product': ['G1',
442+
{'add': {'group': ['G1',
443443
'G2',
444444
'G3',
445445
'G4',
@@ -449,7 +449,7 @@ def test_split_remove_all():
449449
'G8',
450450
'G9',
451451
'G10']}},
452-
{'add': {'product': ['G11']}}],
452+
{'add': {'group': ['G11']}}],
453453
'user': '[email protected]'}
454454

455455

tests/test_functional.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,21 @@ def test_update_user_federatedid_username():
236236
def test_add_org_federatedid():
237237
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
238238
user.add_to_groups()
239-
assert user.wire_dict() == {"do": [{"add": {"product": []}}],
239+
assert user.wire_dict() == {"do": [{"add": {"group": []}}],
240240
"user": "[email protected]"}
241241

242242

243243
def test_add_products_federatedid():
244244
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
245245
user.add_to_groups(groups=["Photoshop", "Illustrator"])
246-
assert user.wire_dict() == {"do": [{"add": {"product": ["Photoshop", "Illustrator"]}}],
246+
assert user.wire_dict() == {"do": [{"add": {"group": ["Photoshop", "Illustrator"]}}],
247247
"user": "[email protected]"}
248248

249249

250250
def test_add_products_federatedid_unicode():
251251
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
252252
user.add_to_groups(groups=["Photoshop", u"Người vẽ minh hoạ"])
253-
assert user.wire_dict() == {"do": [{"add": {"product": ["Photoshop", u"Người vẽ minh hoạ"]}}],
253+
assert user.wire_dict() == {"do": [{"add": {"group": ["Photoshop", u"Người vẽ minh hoạ"]}}],
254254
"user": "[email protected]"}
255255

256256

@@ -283,8 +283,8 @@ def test_add_to_usergroups_federatedid_unicode():
283283

284284
def test_remove_from_products_federatedid():
285285
user = UserAction(id_type=IdentityTypes.federatedID, email="[email protected]")
286-
user.remove_from_groups(groups=["Photoshop", "Illustrator"], group_type="product")
287-
assert user.wire_dict() == {"do": [{"remove": {"product": ["Photoshop", "Illustrator"]}}],
286+
user.remove_from_groups(groups=["Photoshop", "Illustrator"], group_type="group")
287+
assert user.wire_dict() == {"do": [{"remove": {"group": ["Photoshop", "Illustrator"]}}],
288288
"user": "[email protected]"}
289289

290290

umapi_client/functional.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ class IdentityTypes(Enum):
3333

3434

3535
class GroupTypes(Enum):
36+
# product use is deprecated!
3637
product = 1
37-
# group = product # deprecated!
3838
usergroup = 2
3939
productConfiguration = 3
40+
group = 4
4041

4142

4243
class RoleTypes(Enum):
@@ -185,7 +186,7 @@ def add_to_groups(self, groups=None, all_groups=False, group_type=None):
185186
is simply to do an "add to organization Everybody group", so we let that be done.
186187
:param groups: list of group names the user should be added to
187188
:param all_groups: a boolean meaning add to all (don't specify groups or group_type in this case)
188-
:param group_type: the type of group (defaults to "product")
189+
:param group_type: the type of group (defaults to "group")
189190
:return: the User, so you can do User(...).add_to_groups(...).add_role(...)
190191
"""
191192
if all_groups:
@@ -196,7 +197,7 @@ def add_to_groups(self, groups=None, all_groups=False, group_type=None):
196197
if not groups:
197198
groups = []
198199
if not group_type:
199-
group_type = GroupTypes.product
200+
group_type = GroupTypes.group
200201
elif group_type in GroupTypes.__members__:
201202
group_type = GroupTypes[group_type]
202203
if group_type not in GroupTypes:
@@ -209,7 +210,7 @@ def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
209210
Remove user from some PLC groups, or all of them.
210211
:param groups: list of group names the user should be removed from
211212
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type in this case)
212-
:param group_type: the type of group (defaults to "product")
213+
:param group_type: the type of group (defaults to "group")
213214
:return: the User, so you can do User(...).remove_from_groups(...).add_role(...)
214215
"""
215216
if all_groups:
@@ -220,7 +221,7 @@ def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
220221
if not groups:
221222
raise ArgumentError("You must specify groups from which to remove the user")
222223
if not group_type:
223-
group_type = GroupTypes.product
224+
group_type = GroupTypes.group
224225
elif group_type in GroupTypes.__members__:
225226
group_type = GroupTypes[group_type]
226227
if group_type not in GroupTypes:

0 commit comments

Comments
 (0)