Skip to content

Commit 460f35f

Browse files
committed
Test for principal_type
1 parent b8bca20 commit 460f35f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/posit/connect/permissions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def create(self, *args: User | Group, **kwargs) -> Permission | list[Permission]
146146
raise TypeError(f"Invalid argument type: {type(arg)}")
147147
if "principal_guid" in kwargs:
148148
raise ValueError("'principal_guid' can not be defined with `*args` present.")
149+
if "principal_type" in kwargs:
150+
raise ValueError("'principal_guid' can not be defined with `*args` present.")
149151

150152
perms: list[Permission] = []
151153
for arg in args:

tests/posit/connect/test_permissions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,21 @@ def test(self):
190190
role=role,
191191
)
192192

193+
with pytest.raises(TypeError):
194+
permissions.create( # pyright: ignore[reportCallIssue]
195+
"not a user or group",
196+
)
197+
with pytest.raises(ValueError):
198+
permissions.create( # pyright: ignore[reportCallIssue]
199+
User(params, guid=principal_guid),
200+
principal_guid=principal_guid,
201+
)
202+
with pytest.raises(ValueError):
203+
permissions.create( # pyright: ignore[reportCallIssue]
204+
User(params, guid=principal_guid),
205+
principal_type=principal_type,
206+
)
207+
193208
# assert
194209
assert permission == fake_permission
195210

0 commit comments

Comments
 (0)