diff options
author | Frederick Muriuki Muriithi | 2022-11-24 11:36:42 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-24 11:36:42 +0300 |
commit | 1f68ade38e8d3694e7e64f98282ed3eab09feac6 (patch) | |
tree | 27d8922bc0660ced5efeb6da18b8f088b74a72c9 /gn3 | |
parent | d0d08d513e403f7836da450a1d05eaeb89a5ba30 (diff) | |
download | genenetwork3-1f68ade38e8d3694e7e64f98282ed3eab09feac6.tar.gz |
tests: Add test for `create_resource`
* gn3/auth/authorisation/resources.py: Define Resource and ResourceCategory
classes. Create the `create_resource` stub.
* tests/unit/auth/test_resources.py: test for `create_resource` function
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/auth/authorisation/resources.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gn3/auth/authorisation/resources.py b/gn3/auth/authorisation/resources.py new file mode 100644 index 0000000..d01c435 --- /dev/null +++ b/gn3/auth/authorisation/resources.py @@ -0,0 +1,27 @@ +"""Handle the management of resources.""" +from uuid import UUID +from typing import NamedTuple + +from gn3.auth import db +from .groups import Group +from .checks import authorised_p + +class ResourceCategory(NamedTuple): + """Class representing a resource category.""" + resource_category_id: UUID + resource_category_key: str + resource_category_description: str + +class Resource(NamedTuple): + """Class representing a resource.""" + group: Group + resource_id: UUID + resource_name: str + resource_category: ResourceCategory + +@authorised_p(("create-resource",), error_message="Could not create resource") +def create_resource( + conn: db.DbConnection, resource_name: str, + resource_category: ResourceCategory): + """Create a resource item.""" + return tuple() |