diff options
-rw-r--r-- | gn_auth/auth/authorisation/resources/groups/models.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/resources/groups/models.py b/gn_auth/auth/authorisation/resources/groups/models.py index d0aaef8..3189302 100644 --- a/gn_auth/auth/authorisation/resources/groups/models.py +++ b/gn_auth/auth/authorisation/resources/groups/models.py @@ -337,8 +337,14 @@ def resource_from_group(conn: db.DbConnection, the_group: Group) -> Resource: "WHERE group_resources.group_id=?", (str(the_group.group_id),)) results = tuple(resource_from_dbrow(row) for row in cursor.fetchall()) - assert len(results) == 1, "Expected a single group resource." - return results[0] + match len(results): + case 0: + raise InconsistencyError("The group lacks a wrapper resource.") + case 1: + return results[0] + case _: + raise InconsistencyError( + "The group has more than one wrapper resource.") def remove_user_from_group( |