Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/user_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def get_audit_events(
them.
actor_kind: Only changes made by a person (``"PERSON"``), or only
by automations (``"AUTOMATION"``).
types: Only these kinds of events.
types: Only these kinds of events: one type or a list of them.
project: Only events of this project: a group attached to or
detached from it.
occurred_after: Only events at or after this moment.
Expand Down
4 changes: 4 additions & 0 deletions libs/labelbox/src/labelbox/schema/user_group_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ def get_user_group_audit_events(
before = _to_datetime("occurred_before", occurred_before)
if after and before and after >= before:
raise ValueError("occurred_after must be before occurred_before")
# A single type (a string or an enum member, which is also a string)
# would otherwise be iterated one character at a time.
if isinstance(types, str):
types = [types]
where = {
key: value
for key, value in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ def test_get_audit_events_without_group_and_unknown_values(self, client):
"projectId": "project_1"
}

@pytest.mark.parametrize(
"types", ["MEMBER_ADDED", UserGroupAuditEventType.MEMBER_ADDED]
)
def test_accepts_a_single_type(self, group, client, types):
client.execute.return_value = {
"userGroupAuditEvents": {"nodes": [], "nextCursor": None}
}

list(group.audit_events(types=types))

assert client.execute.call_args[0][1]["where"]["types"] == [
"MEMBER_ADDED"
]

def test_rejects_bad_filters(self, group, client):
with pytest.raises(ValueError):
group.audit_events(actor_kind="ROBOT")
Expand Down